In LINUX, automatic backup is very important to data security. How can we achieve automatic backup to retain data in the last few days? The following uses the bucket Classification Website www.yes81.net as an example for testing. The attachments uploaded by Forum users on the website, the attachments uploaded by the main system of the bucket and the database are an important data that must be backed up.
This server uses an array of dual hard disks, so there is no worries about data loss due to hard disk crash, mainly due to system problems or misoperations.
1. Hard Disk Partition backdata is used for backup.
2. mydata is a data partition, mysql is a database file directory, bbs is the file directory of the Forum, and yes81 is the file directory of the main site yes81.net
Now our goal is to complete the daily automatic backup, and retain only 10 days of data, the data is automatically deleted 10 days ago
For this reason, we have compiled the following automatic backup batch file, and added the task automatically executed at every morning in the crontab schedule.
----------------- Bacpupdata. bat -------------------------------------
Cd/backdata
# ---- Delete the backup 10 days ago
Date-d-15-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
Date-d-14-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
Date-d-13-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
Date-d-12-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
Date-d-11-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
Date-d-10-day + % Y-% m-% d> dd.txt
Read dateold <dd.txt
Rm dd.txt-f
Rm-rf $ dateold
# ----- Create a new file backup for the day
Date-d 0-day + % Y-% m-% d> dd.txt
Read date1 <dd.txt
Rm dd.txt-f
Mkdir $ date1
Rar a/backdata/$ date1/database1_date1.rar/mydata/mysql
Rar a/backdata/$ date1/bbs1_date1.rar/mydata/bbs/WEB-INF/lybbs/upload
Rar a/backdata/$ date1/buyi?date1.rar/mydata/yes81
The copyright of this post belongs to http://free.yes81.net/yes81/view-1169.html. For more information, please copy this address.