Daily seven o'clock in the morning back up your company's web site plan

Source: Internet
Author: User

To prevent an unexpected situation and cause the site to be unavailable, make a daily backup of the Tomcat entire station

Wrote a script placed in the/etc/rc.d/directory, named rotate.sh

To prevent daily backups from taking up too much space, delete the backups from 4 days ago and roll back the operations

1. Write Script rotate.sh

#!/bin/sh

Path= $PATH:/bin:/sbin

Export PATH

Year= ' Date +%y '

Month= ' Date +%b '

day= ' Date +%d '

now1= $year-$month-$day

now= $day/$month/$year

Cd/mnt/backup

Find./-type f-mtime +3-exec rm {} \;

cd/mnt/backup/

Tar zcvf aidonghtml$now1.gz/mnt/tomcat/

#mysqldump-uroot-p6112911218 aidong > Aidong$now1.sql

#mysqldump-uroot-p6112911218 aidong2 > Aidong2$now1.sql

#tar ZCVF aidong$now1.gz Aidong$now1.sql

#tar ZCVF aidong2$now1.gz Aidong2$now1.sql

#rm-RF *.sql

2. Execute the task plan and execute the above script at 7:7 A.M. every day

#crontab-L

7 7 * * */etc/rc.d/rotate.sh

3. View the results performed daily

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7A/08/wKiom1ahhsbxYQU8AAAX-Vi4OU8622.png "title=" q@q~n0 ] (x152acw%_jqtgi9.png "alt=" Wkiom1ahhsbxyqu8aaax-vi4ou8622.png "/>


This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1737522

Daily seven o'clock in the morning back up your company's web site plan

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.