Linux How to do batch processing automatically keep a few days of backup

Source: Internet
Author: User
Keywords Linux

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Automatic backup under Linux is important to the security of the data, how do you keep the data in the last few days when you do automatic backup? Below to the cloth classification Life Network www.yes81.net as an example to carry out the test, the website of the Forum to upload the submission of the attachment, The main system of the cloth Living website uploads the attachment as well as the database is an important data that must be backed up.

The server uses an array of dual hard drives, so the hard disk crash data is not worried, the main concern is due to system problems or misoperation caused by data loss.

1, hard disk partition backdata is specifically used as a backup

2, MyData is the data partition, MySQL is the database file directory, BBS is the forum file directory; Yes81 is the main station yes81.net file directory

Now our goal is to complete the automatic daily backup, and only 10 days of data retention, 10 days before the data automatically deleted

For this we have written the following automatic backup batch file, and in the crontab scheduling, increased the 3-point automatic daily tasks.

-----------------Bacpupdata.bat-------------------------------------

Cd/backdata

#----Delete 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

#-----File backup for the new Day

date-d 0-day +%y-%m-%d > Dd.txt

Read Date1 < Dd.txt

RM dd.txt-f

mkdir $date 1

RAR a/backdata/$date 1/database$date1.rar/mydata/mysql

RAR a/backdata/$date 1/bbs$date1.rar/mydata/bbs/web-inf/lybbs/upload

RAR a/backdata/$date 1/buyi$date1.rar/mydata/yes81

This paste copyright belongs to http://free.yes81.net/yes81/view-1169.html, reprint please copy this address

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.