备份目录的脚本

# vi tarweb.sh

#!/bin/bash

Date=`date +%y%m%d`

olddate=`date +%y%m%d -d "-7 days"`
mkdir /back/$Date
mkdir /logs/$Date
rm -rf /back/$olddate
rm -rf /logs/$olddate
echo "web back begin at `date +%H:%M:%S`" >> /logs/$Date/back.log
tar czf /back/$Date/web.tar.gz /date/web
echo "web back end at `date +%H:%M:%S`" >> /logs/$Date/back.log

:wq

脚本注释:

1、备份web目录

2、记录备份开始和结束的时间(几点几分几秒)