Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Atlassian Linux Shell Scripting the confluence remote backup methods     - How to troubleshoot error java.lang.NoSuchMethodError (Programming)

- Mac OS X 10.10 Yosemite compiling OpenJDK 9 (Linux)

- Differences Shell scripting languages and compiled languages (Programming)

- CentOS 7 hard disk expansion toss record (Linux)

- How to configure Proftpd server on Fedora 22 (Server)

- Linux6.1 / 6.5 dual-NIC Binding (Linux)

- Restrict console access to Linux servers to improve security (Linux)

- GoldenGate update is missing (Database)

- CentOS 6.5 installation and simple configuration Nginx (Server)

- Asynchronous JavaScript loading (Programming)

- Linux System Getting Started Learning: Repair fatal error openssl aes h no such file or directory (Linux)

- Git commands (Linux)

- Why do I prefer Git (Linux)

- Linux shell script to adjust the Task Scheduler (Linux)

- The Java development environment to build under Ubuntu 14.04 (Linux)

- Install Unity 8 preview version of the desktop in Ubuntu (Linux)

- Timeout control related to Python threads and a simple application (Programming)

- KVM add virtual disks (Linux)

- netfilter- in kernel mode network packet operation (Linux)

- Memcached distributed caching (Server)

 
         
  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:      
 
- How to use the Linux kill command to kill the process / program is not responding (Linux)
- Linux Getting Started Tutorial: Ubuntu laptop screen brightness adjustment (Linux)
- CRF ++ Linux use (Linux)
- Linux Getting Started tutorial: 3D effects and beautify your desktop (Linux)
- CentOS NAT iptables (Linux)
- MySQL partition summary (Database)
- Linux commands to access the cheat sheet (Linux)
- MongoDB relations, references, index query coverage (Database)
- How to Use Nmap security scanner tool on Linux (Linux)
- YUM install desktop environment in CentOS (Linux)
- Oracle RAC node on the expulsion of the inspection process on OEL6.3 (Database)
- Installation Android IDE development tools, Android Studio 1.5 under Ubuntu (Linux)
- How to Start a Linux application running in the background using the terminal mode (Linux)
- Three minutes to teach you to easily grasp the grep command regular expression (Linux)
- 5 fast Node.js application performance tips (Programming)
- Binary tree traversal: the first sequence in order preorder recursive and non-recursive and traversal sequence (Programming)
- To install the Contiki development toolchain on Ubuntu (Linux)
- Commonly used Linux system camouflage method (Linux)
- To install MySQL 5.6 binary packages under CentOS 6.4 64bit (Database)
- The Objects in JavaScript (Programming)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.