Dual-host (multi-host) automatic mutual backup solution in Linux

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

######################################## ################################
Related Article

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.