Back up the company's web site plan at 07:00 every morning
In order to prevent the website from becoming unavailable due to unexpected situations, the whole tomcat site is backed up every day.
Write a script and put it in the / etc/rc.d/ directory with the name rotate.sh
In order to prevent the daily backup from taking up too much space, delete the backup before 4 days every day and roll back the operation.
1. Write a 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
two。 Execute the task plan and execute the above script at 07:07 every morning
# crontab-l
7 7 * / etc/rc.d/rotate.sh
3. View the results of daily execution