& Nbsp; problem: two LINUX servers, each with 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. Objective: host machine (eventually all backups are stored on it) ship machine (save host machine backup)
Question: Two LINUX servers each have 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:
# // Host machine script ///////////////#! /Bin/sh HOST = "abc.com" USER = "backup_use" # ship machine backup_use user password = "backup_use" # ship machine user password 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/bin: /usr/local/nusphere/mysql/bin DOW = 'date + % a' DM = 'date + % Y % B % d' file1?ship-=al-=dm.tar.gz ##fil1 = $ BACKUPDIR2/ host-main-mongodm.tar.gz FIL2 = $ BACKUPDIR2/mongofil3 = $ BACKUPDIR2/supervisor # DIRECTORIE1 = "/www/home/jjd" # directory to be backed up 1 DIRECTORIE2 = "/etc/var/named/ usr/local/nusphere/apache/conf "# directory to be backed up 2 # if [$ DOW =" Sat "]; then # full backup of tar-zcpf $ FIL1 $ DIRECTORIE1 tar-zcpf $ FIL3 $ DIRECTORIE2 mysqldump -- all-databases-q-uroot-p $ MYSQLPASS | gzip> $ FIL2 ftp- i-n <$ BACKUPDIR/$COMPUTER-mysqldata-$DM.tar.gz fi ############################### ######################################## #
|