linux中基于时间的增量备份
#!/bin/bash
BACKUP_S=/tmp/kevintmp
BACKUP_T=/tmp/backup
TIME_KEY_F=/tmp/kevintmp/.time-key
DATETIME=$(date +%y%m%d%H%M)
all()
{
touch $TIME_KEY_F
cp -a $BACKUP_S $BACKUP_T/$DATETIME
}
update()
{
if [ ! -f $TIME_KEY_F ];then
return 1
fi
cd $BACKUP_S | | return 1
touch $TIME_KEY_F.tmp
find ./ -newer $TIME_KEY_F -type f >/tmp/file_list.list
find ./ -newer $TIME_KEY_F -type d >/tmp/dir_list.list
mkdir -p $BACKUP_T/$DATETIME
tar -cf -T /tmp/file_list.list | tar -x -C $BACKUP_T/$DATETIME
while read DIR_name
do
mkdir -p $BACKUP_T/$DATETIME/$DIR_name
done
mv $TIME_KEY_F.tmp $TIME_KEY_F
}
all