Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Atlassian Linux Shell Scripting the confluence remote backup methods     - Understand the profound discussion of some of the options for wireless encryption (Linux)

- Ubuntu 12.04 64-bit installation Redmine + Git + ReviewBoard (Linux)

- DupeGuru- find and remove duplicate files (Linux)

- IOS interview questions Summary (Programming)

- libnet list of functions (Programming)

- Three binary tree traversal (recursive, non-recursive traversal and Morris) (Programming)

- Netcat Example (Linux)

- lack of SWAP space during installation of Oracle (Database)

- Using Lua implement various operations list (Programming)

- Gitlab installation under CentOS 7 (Linux)

- CentOS directory structure Explanation (Linux)

- Docker: installation under Ubuntu (Server)

- To install Samba server on CentOS 6.6 (Server)

- Linux script to copy the folder to all folders with the same name (Linux)

- Oracle Database Performance Optimization of memory disk (Database)

- Oracle 11g RAC manually playing GI PSU patch (11.2.0.4.8) (Database)

- Compile and install the latest version of Redis Stable (Database)

- Linux Command Tutorial: du command to view disk space (Linux)

- Linux installed and tested the deployment of Kafka distributed cluster (Server)

- Revised OpenJDK Java Memory Model (Programming)

 
         
  Atlassian Linux Shell Scripting the confluence remote backup methods
     
  Add Date : 2018-11-21      
         
         
         
  NOTE: Atlassian confluence wiki is a more professional program, by the java language, the details of which can Google it (a little fly in the ointment, java take up memory is quite large).

The script is based on the idea of ​​design documentation Atlassian confluence official written primarily to back up configuration files, databases and other files uploaded some attachments and the like, its database supports multiple databases, this time I used PostgreSQL database, you can use your own familiar database, such as MySQL.

Problems doubts:

1. Why not use rsync instead use scp as remote file transfer method?

While the rsync algorithm design (specific algorithm can refer to Chen Hao Bowen "rsync algorithm core") determined that it is more suitable as a backup during file transfer, such as support for incremental backups and compression and transmission, but does not require a backup Atlassian confluence with real-time, and in the script has done a deal with the history of backups (backups automatically deleted 10 days ago), backup script used in equivalent full backup, but not incremental backup, followed by backup multiple execution at night, and mostly within the network transmission, timely Atlassian confluence on the cloud Ali, also a network IP address, so do not over-worry about traffic problems.

2. Why do you want to execute the script on the backup machine?

In fact, this script is run on the backup machine or Atlassian confluence machines are possible, but in order to reduce the number of ssh remote command execution, and place it on the backup machine to perform a bit better.

TODO 3.find after that why?

In the actual testing process we found that even find without any deletion, also returns 0, which was successful. So check back and complete the message and does not reflect the results of the find. If you have a better way in the future, and then added to it.

Backup script as follows:

#! / Bin / bash
 
# Touch confluence_backup.sh
# Chmod + x confluence_backup.sh
# Vim confluence_backup.sh
 
# Crontabs - configuration and scripts for running periodical jobs
# SHELL = / bin / bash
# PATH = / sbin: / bin: / usr / sbin: / usr / bin
# MAILTO = root
# HOME = /
# For details see man 4 crontabs
# Example of job definition:
# .---------------- Minute (0 - 59)
# | .------------- Hour (0 - 23)
# | | .---------- Day of month (1 - 31)
# | | | .------- Month (1 - 12) OR jan, feb, mar, apr ...
# | | | | .---- Day of week (0 - 6) (Sunday = 0 or 7) OR sun, mon, tue, wed, thu, fri, sat
# | | | | |
# * * * * * User-name command to be executed
# M h dom mon dow command
# Execute on 11:59 per sunday
# 59 11 * * * / 0 $ 0> / tmp / confluence_backup _ $ (date -d "yesterday" + "% Y% m% d% H% M% S"). Log
# Or
# Execute on 23:59 per day
# 59 23 * * * $ 0> / tmp / confluence_backup _ $ (date -d "yesterday" + "% Y% m% d% H% M% S"). Log
 
# Xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
# | Ssh tunnel |
# Xxx.xxx.xxx.xxx <==========> xxx.xxx.xxx.xxx
# | |
# ------- + ---------- + -----------------------------
# | |
# + + ----- + ----- + ------ + ------ +
# | A | | B |
# + + ------------- + ----------- +
# Gitlab server backups clinet
#
# This shell script will execute on B Server
# A and B passed ssh Authentication
# A -> B: ssh lan_ip
# A -> B: ssh wan_ip
# B -> A: ssh lan_ip
# B -> A: ssh wan_ip
# A -> A: ssh lan_ip
# A -> A: ssh wan_ip
# B -> B: ssh lan_ip
# B -> B: ssh wan_ip
 
# Run with root
# [$ (Id -u) -eq 0] || exit 1
# Run as root, of course.
[$ UID -eq 0] || (echo "Must be root to run this script." && Exit 1)
 
# Save 10 days
save_days = 10
 
# Which directory to backup to
backup_path = / data / confluence_backup_directory
# Make backups uniqure and backup per day
# Backup_path_time_uniq = $ (date -d "yesterday" + "% Y% m% d% H% M% S")
backup_path_time_uniq = $ (date -d "yesterday" + "% Y% m% d")
confluence_home_directory = / data / var / atlassian / application-data / confluence
# If you have both wan ip and lan ip, you can fill it with all, if you have one ip, you can fill it just with lan ip
confluence_server_ipaddress_public = xxx.xxx.xxx.xxx
confluence_server_ipaddress_private = xxx.xxx.xxx.xxx
# Select lan ip first for transmission speed
confluence_server_hostname = $ {confluence_server_ipaddress_private: - $ confluence_server_ipaddress_public}
confluence_server_ssh_username = root
#confluence_server_ssh_port = $ (awk '/ Port / {print $ 2}' / etc / ssh / sshd_config)
confluence_server_ssh_port = $ (netstat -anop | awk '/ sshd / && / LISTEN / {print $ 4}' | awk -F ':' '{print $ 2}')
confluence_server_ssh_hostname = $ confluence_server_hostname
 
# Which files and directory backup
# Backup_files = (confluence.cfg.xml attachments config index)
backup_files = (confluence.cfg.xml attachments index)
backup_files_num = $ {# backup_files [@]}
[-d $ Backup_path / $ backup_path_time_uniq] || mkdir -p $ backup_path / $ backup_path_time_uniq
 
# Do ssh copy
for ((i = 0; i <$ backup_files_num; i ++)); do
    scp -r -P $ confluence_server_ssh_port $ confluence_server_ssh_username @ $ confluence_server_ssh_hostname: $ confluence_home_directory / $ {backup_files [i]} $ backup_path / $ backup_path_time_uniq> / dev / null 2> & 1
    [? $ -ne 0] && echo "$ confluence_home_directory / $ {backup_files [i]} Backup failed!" && Exit 1; echo "$ confluence_home_directory / $ {backup_files [i]} Backup successfully!"
done
# Excution postgresql dump
# PostgreSQL 9.3.9 Documentation :: 31.14. Environment Variables
# PGHOST = 127.0.0.1
# PGHOSTADDR = 127.0.0.1
# PGPORT = 5432
# PGDATABASE = confluence
# PGUSER = confluence
# PGPASSWORD = yoursecret
# PostgreSQL 9.3.9 Documentation :: 31.15. The Password File
#cat> ~ / .pgpass << eof
# 127.0.0.1: 5432: confluence: confluence: yoursecret
#eof
# WARNING: password file "/root/.pgpass" has group or world access; permissions should be u = rw (0600) or less
#chmod 600 /root/.pgpass
#pg_dump -U confluence -d confluence -h 127.0.0.1 -o | head
# Important: If your database schema relies on OIDs (for instance, as foreign keys) you must instruct pg_dump to dump the OIDs as well To do this, use the -o command-line option..
echo "PostgreSQL is executing backup operation, please hold on!"
ssh -P $ confluence_server_ssh_port $ confluence_server_ssh_username @ $ confluence_server_ssh_hostname "pg_dump -U confluence -d confluence -h 127.0.0.1 -o> /tmp/tmp_confluence_postgresql.sql"
[? $ -ne 0] && echo "PostgreSQL dump failed!" && Exit 1; echo "PostgreSQL dump successfully!"
scp -P $ confluence_server_ssh_port $ confluence_server_ssh_username @ $ confluence_server_ssh_hostname: /tmp/tmp_confluence_postgresql.sql $ backup_path / $ backup_path_time_uniq / confluence_postgresql _ $ (date -d "yesterday" + "% Y% m% d") sql> / dev / null 2. > & 1
[? $ -ne 0] && echo "PostgreSQL file transmission failed!" && Exit 1; echo "PostgreSQL file transmission successfully!"
# Delete old backups
find $ backup_path -mtime + $ save_days -exec rm -rf {} \;
# TODO
# Returned code always is 0, from find or rm ???
# How to express real result?
[? $ -ne 0] && echo "Local expired backups remove skipped!"; Echo "Local expired backups remove successfully!"
     
         
         
         
  More:      
 
- Linux centos rm directory does not prompt (Linux)
- Ubuntu update bug fixes Daquan (Linux)
- C language programming entry - macro definitions and enum (Programming)
- DM9000 bare Driver Design (Programming)
- Let Linux operating system more secure (Linux)
- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (Linux)
- MySQL completely uninstall and install Configuring Character Sets under Linux (Database)
- RPM package creation Getting Started (Linux)
- Elaborate 10-point difference between the new and malloc (Programming)
- Django1.8 return json json string and the string contents of the received post (Programming)
- Nginx1.8 version upgrade method AMH4.2 Free manually compile (Server)
- Batch download files using the explorer under Windows Server 2008 R2 (Server)
- Getting case of Python Hello World (Programming)
- File permissions under Linux (Linux)
- OpenCV 3.0 + Python 2.7 installation and testing under Ubuntu 14.04 (Linux)
- Python KNN algorithm of actual realization (Programming)
- Java reflection mechanism explained in detail and Method.invoke explanation (Programming)
- Ubuntu 14.04 Nvidia proprietary drivers for install two graphic cards (Linux)
- CentOS 6 kernel upgrade to Kernel 3.x (Linux)
- Linux, security encryption to transfer files between machines (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.