Linux tar full Incremental backup script

Source: Internet
Author: User

As the company's website increases and the occupied space increases, 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
 

Related Article

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.