File backup Under Linux

Source: Internet
Author: User

Script Description:
File backup is the basic work of Linux system maintenance, and this script uses an incremental backup of tar, which can be added to crontab in timed execution.
The directory or files that the script backs up are all written to a file in Cfg_file.

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/97/72/wKiom1kueZ-gabDUAAAtougU6Vc463.png-wh_500x0-wm_ 3-wmp_4-s_411437824.png "style=" Float:none; "title=" Run3.png "alt=" Wkiom1kuez-gabduaaatougu6vc463.png-wh_50 "/>

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/97/73/wKioL1kueZ-BxfKuAAA8fkoCpeY719.png-wh_500x0-wm_ 3-wmp_4-s_1499273299.png "style=" Float:none; "title=" Run1.png "alt=" wkiol1kuez-bxfkuaaa8fkocpey719.png-wh_50 "/ >

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/97/73/wKioL1kueaCC9aZ9AABVuw-Hr3I607.png-wh_500x0-wm_ 3-wmp_4-s_3210348197.png "style=" Float:none; "title=" Run2.png "alt=" wkiol1kueacc9az9aabvuw-hr3i607.png-wh_50 "/ >


#cat/data/sh/backup.sh

#!/bin/bash
#file increament Backup
#by Slitobo 2017/5/31

Des_dir=/data/backup_dir
inc_dir= $DES _dir/snapshot
Inc_file=snapshot
date_dir= $DES _dir/$ (date +%y%m%d)
inc_tar_file=inc_$ (date "+%y%m%d-%h%m"). tar.gz

EXEC < Cfg_file

[-D $DES _dir] | | Mkdir-p $DES _dir &>/dev/null
[-D $INC _dir] | | Mkdir-p $INC _dir &>/dev/null
[-D $DATE _dir] | | Mkdir-p $DATE _dir &>/dev/null
While read filename
Do
if [!-d $filename] && [!-F $filename];then
Echo-e "\033[31m $filename is not exists! Please Check Path!!! \033[0m "
Sleep 2
Else
file=$ (basename $filename)
dir=$ (dirname $filename)
Var=$ (echo ${filename:1} | sed ' [email protected]/@[email protected] ')
#echo $var
CD $DIR
Tar-g $INC _dir/"$var" _$INC_FILE-CZVF $DATE _dir/"$var" _$inc_tar_file $FILE &>/dev/null
echo "$DATE _dir/" $var "_$inc_tar_file created ..."
Fi
Done



This article is from the "remote to the South" blog, please be sure to keep this source http://slitobo.blog.51cto.com/12957087/1931017

File backup Under Linux

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.