Dual-host/multi-host automatic mutual backup solution in Linux

Source: Internet
Author: User
Tags mysql 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 ############################### ######################################## #
       

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.