Offsite Backup Synchronization Check Script

Source: Internet
Author: User

Implementation features: The Daily data (/www,/log) of client Server A is packaged locally, and the scheduled script is synchronized to the server on the server every day, and the backed up data is verified on the servers, and the results are sent to the administrator's mailbox. Client:
#!/bin/bashremote_host=172.16.1.111    remote_path=/backup          local_backup_path=/backuplocal_file_path=/data [-D $local _backup_path]| | Mkdir-p $local _backup_path #打包 cd ${local_file_path}&& tar zcf $local _backup_path/www-$ (date +%f). tar.gz/data/ www && tar zcf $local _backup_path/log-$ (date +%f). Tar.gz/data/log && find/backup-type f-name "*.tar.gz "| Xargs md5sum > $local _backup_path/flag_$ (Date +%f) #同步rsync-avz  $local _backup_path/*  $remote _host:$ Remote_path--PASSWOD (omitted) #删除本地七天前find $local _backup_path-type f-name "*.tar.gz"-mtime +7| Xargs rm-f

  

Join a timed task
crontab-e04***  /bin/bash/root/shell/www_backup.sh &>/dev/null

  

Service side:
#!/bin/bashlocal_backup_path=/backupmd5_file=flag_$ (date +%f) CD $local _backup_path if[$?-eq 0];then    if[-e $md 5_ File];then        md5sum-c ${md5_file}>> mail.txt        if[$?-eq 0];then            mail-s "Success! The backup task is OK! " [Email protected] < Mail.txt        else             mail-s "Failed! The backup task is failed! " [Email protected] < Mail.txt                fi      else         ls > mail.txt        mail-s "Failed! The md5_file is not exists! " [Email protected] < Mail.txt fi

  

Join a timed task
crontab-e05***  /bin/bash/root/shell/flag_check.sh &>/dev/null

  



From for notes (Wiz)



Offsite Backup Synchronization Check Script

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.