Dual-Machine (multi-computer) automatic mutual backup scheme in Linux environment

Source: Internet
Author: User
Tags ftp mysql backup mysql database backup linux

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.