Linux Learning note-rsync+crond scheduled backup service

Source: Internet
Author: User
Tags rsync

Scheduled backup data scheme

1th. Backup Requirements

there's one in the company. Web Server, the data inside is very important, but if the hard drive is broken, the data is lost, and now the leader asks you to make a periodic backup of the data on other machines. Requirements are as follows:

every night xx Point the whole Web Server A The backup system configuration file, the website program directory, and the access log, and rsync command push to server B Backup Retention (backup ideas can be packaged locally by date before being pushed to the backup server B on).

The specific requirements are as follows:

1) The backup directory for both Web server A and backup server B must be/backup.

2) The system configuration files to be backed up include, but are not limited to:

A. configuration files for timed tasks (/var/spool/cron/root)

B. boot -up configuration file (/etc/rc.local)

C. directory of daily Scripts (/service/scripts)

D. firewall iptables configuration file (/etc/sysconfig/iptables)

3) the Web Server site directory is assumed to be (/var/html/www)

4) Web server A Access log path assumed to be (/app/logs)

5) The Web server retains the packaged 7 Days of backup data (local retention cannot be more than 7 days, because too many hard drives are full)

6) Backup server B names the backup folder according to the IP address of the backup data server , the Saturday data is retained , and the other backups retain only the days of the backup.

7) on backup server B , check that the backup results are normal and send the daily backup results to the administrator.

The 2nd Chapter realizes the thought 2.1File Packaging Commands

Packaging command:tar-zxvf name.tar.gz $file

Example: Package file /etc/hosts to /back directory, package file name test.tar.gz

[[email protected] ~]# Ls/backup/[[email protected] ~]#[[email protected]/]# CD/&& TAR-ZCVF/BACKUP/TEST.TAR.G Z etc/hostsetc/hosts[[email protected]/]# ls/backup/test.tar.gz
2.2Package by Date

command to get the current date:date+%f

Example: Packaging files /etc/hosts to /back directory, package file names are differentiated by date

[[Email protected]/]# CD/&& tar-zcvf/backup/$ (Date +%f). tar.gz etc/hostsetc/hosts[[email protected]/]# ls/ba Ckup/2017-11-04.tar.gz test.tar.gz
2.3Saturday Package Special name

Because the server needs to keep the Saturday package, you need to give the file a special name in order to differentiate it when you package the Saturday file.

[[Email protected]/]# CD/&& tar-zcvf/backup/$ (date +%f) _week6.tar.gz Etc/hostsetc/hosts[[email protected]/]# ls/backup/2017-11-04.tar.gz 2017-11-04_week6.tar.gz test.tar.gz
2.4uploading files to the server

The steps to install the Rsync service are omitted by uploading the file to the specified directory on the backup server via the rsync service .

Test upload:

[Email protected]/]# rsync-avz/backup/$ (date+%f). tar.gz [Email protected]::backup--password-file=/etc/ Rsync.passwordsending Incremental list2017-11-04.tar.gz sent 305 bytes received bytes 664.00bytes/sectotal size I S 223 speedup is 0.67

Note: Place the packaged files in the/backup/ local ip/ directory and upload the entire IP directory

2.5Data Validation

command:md5sum

Md5sum has the function of data verification, the practice is to use the md5sum command to generate a checksum file, and then put this check code in an arbitrary file, and then use the md5sum-c parameter to check for changes. The following are the specific practices:

    • Generate a checksum file for the file:

[Email protected] backup]# ls2017-11-04.tar.gz[[email protected] backup]# md5sum2017-11-04.tar.gz b29cee519b7991a429c353b11c01d533 2017-11-04.tar.gz[[email protected] backup]# md5sum 2017-11-04.tar.gz> md5sum_ Check #<== generates a unique checksum and writes it to the file [[email protected] backup]# cat md5sum_checkb29cee519b7991a429c353b11c01d533 2017-11-04. tar.gz

Linux Learning note-rsync+crond scheduled backup service

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.