In Linux, the dual-host (multi-host) automatic mutual backup solution-Linux Enterprise Application-Linux server application information. The following is a detailed description. Question: Our company has two LINUX servers, each of which has only one hard disk. Therefore, the backup issue is particularly important. We have a mysql database installed. Of course, we also need to solve the problem of mysql backup.
Project: host Machine (all backups are stored on it) ship Machine (save host Machine backup)
Method: use shell scripts to package the files to be backed up. Then download the file through ftp and upload the solution.
The root of the two machines uses crontab to schedule the scripts on their respective machines.
We recommend that you host at every day.
Recommended ship at every morning
Note:
The system time difference between the two servers should be no more than one hour.
This script backs up data every week 6 weeks. Of course, you can also change it to monthly or daily backup.
You can also change it to an incremental backup script.
Specific script:
The host machine script is as follows:
CODE: # // host script ///////////////
#! /Bin/sh
HOST = "abc.com"
USER = "backup_use" # ship Machine backup_use USER
PASSWORD = "backup_use" # PASSWORD of the ship Machine
BACKUPDIR = "/home/backup_use/ship" # host machine backup_use user directory
BACKUPDIR2 = "/home/backup_use/host" # host machine backup_use user directory
MYSQLPASS = "abc" # ship Machine mysql root User Password
PATH =/usr/local/bin:/usr/local/nusphere/mysql/bin
DOW = 'date + %'
DM = 'date + % Y % B % d'
File1‑ship-‑al-‑dm.tar.gz
File2‑ship-mysqldata-mongodm.tar.gz
File3‑ship-szeasy-‑dm.tar.gz
File4‑ship-other-‑dm.tar.gz
#
FIL1 = $ BACKUPDIR2/host-main-domaindm.tar.gz
FIL2 = $ BACKUPDIR2/host-mysqldata-mongodm.tar.gz
FIL3 = $ BACKUPDIR2/host-other-mirrordm.tar.gz
#
DIRECTORIE1 = "/www/home/jjd" # directory 1 to be backed up
DIRECTORIE2 = "/etc/var/named/usr/local/nusphere/apache/conf" # directory 2 to be backed up
#
If [$ DOW = "Sat"]; then # Full backup every Saturday
Tar-zcpf $ FIL1 $ DIRECTORIE1
Tar-zcpf $ FIL3 $ DIRECTORIE2
Mysqldump -- all-databases-q-uroot-p $ MYSQLPASS | gzip> $ FIL2
Ftp-I-n <$ BACKUPDIR/unzip computer-mysqldata-mongodm.tar.gz
Fi
######################################## ################################ |