Problem: Our company has two Linux servers, one hard drive per server. So the question of backup is particularly important. We have a MySQL database installed. Of course, but also to solve the problem of MySQL backup.
Purpose: Host machine (eventually all backups are left on its back) ship machine (save host machine Backup)
Method: Package The files to be backed up with a shell script. Then through the FTP operation download, upload complete solution.
The two machines root through crontab to allow the scripts to be timed on their respective machines.
Recommended host 3 O ' Day in the morning
Recommended ship 6 O ' Day in the morning
Note the point:
The best time for two server systems is not to exceed 1 hours.
This script is backed up 6 weeks a week. Of course you can also modify the monthly or daily backup.
Of course, you can also modify it into an incremental backup script.
Specific script:
The following is the host machine script
#//////////////host Machine Script///////////////
#! /bin/sh
Host= "ABC.com"
User= "Backup_use" #ship机器backup_use用户
Password= "Backup_use" #ship机器对应用户密码
Backupdir= "/home/backup_use/ship" #host机器backup_use用户目录
Backupdir2= "/home/backup_use/host" #host机器backup_use用户目录
mysqlpass= "abc" #ship machine mysql root user password
Path=/usr/local/bin:/usr/bin:/bin:/usr/local/nusphere/mysql/bin
dow= ' Date +%a '
dm= ' Date +%y%b%d '
file1=ship-virtual-$DM. tar.gz
file2=ship-mysqldata-$DM. tar.gz
file3=ship-szeasy-$DM. tar.gz
file4=ship-other-$DM. tar.gz
#
fil1= $BACKUPDIR 2/host-main-$DM. tar.gz
fil2= $BACKUPDIR 2/host-mysqldata-$DM. tar.gz
fil3= $BACKUPDIR 2/host-other-$DM. tar.gz
#
Directorie1= "/WWW/HOME/JJD" # directory to back up 1
Directorie2= "/etc/var/named/usr/local/nusphere/apache/conf" # directory to back up 2
#
if [$DOW = "Sat"]; Then # Six full backups per week
TAR-ZCPF $FIL 1 $DIRECTORIE 1
TAR-ZCPF $FIL 3 $DIRECTORIE 2
mysqldump--all-databases-q-uroot-p$mysqlpass |gzip > $FIL 2
Ftp-i-N < $BACKUPDIR/$COMPUTER-mysqldata-$DM. tar.gz
Fi
########################################################################
Jp