As the company's website increases and the occupied space increases, write a script. Under incremental backup & nbsp ;#! /Bin. bash # backup00: 00: 00week 'date + % u'date' date + % Y-% m-% d 'year' Date + % Y' month 'date + % m'day' date + % d 'bakpath/var/bak/webbakweb is occupying more and more space as the company's website increases, therefore, write a script. Under incremental backup
#! /Bin. bash
# Backup 00:00:00
Week = 'date + % u'
Date = 'date + % Y-% m-% d'
Year = 'date + % Y'
Month = 'date + % M'
Day = 'date + % d'
Bakpath =/var/bak/webbak
Webpath =/var/htmlwww
Wzbakup =/var/bak/webbak/wzbf
Backup = $ bakpath/$ year/$ month/$ (date + % d-d "1 day ago ")
Web = (web1 web2 web3)
For I in 'ls $ webpath'
Do
If [[$ week-ne 1]; then
If [! -D $ backup]; then
Mkdir-p $ backup/$ I
Mkdir-p $ bakpath/$ I
Fi
Tar-g $ bakpath/$ I .txt-zPcf $ backup/$ I .tar.gz $ webpath/$ I
Else
If [! -D $ wzbakup]; then
Mkdir-p $ wzbakup
Fi
Cd $ wzbakup
Tar-g $ bakpath/$ I .txt-zcPf $ PWD/$ I ?date.tar.gz $ webpath/$ I
Rm-rf $ I $ (date + % Y-% m-% d-d "7 days ago" 2.16.tar.gz
Rm-rf $ backup /*
Fi
Done
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