数据滚动备份脚本:
#!/bin/bash
if [ ! -d "/archives/mercurialnewbak/mercurial-server" ]; then
rsync -aP devgit1:/var/lib/mercurial-server /archives/mercurialnewbak
else
if [ -d "/archives/mercurialnewbak/mercurial-server.7" ];then
rm -rf /archives/mercurialnewbak/mercurial-server.7
i=6
while [[ $i -ge 1 ]]
do
let a=$i+1
mv /archives/mercurialnewbak/mercurial-server.$i /archives/mercurialnewbak/mercurial-server.$a
let i=$i-1
done
mv /archives/mercurialnewbak/mercurial-server /archives/mercurialnewbak/mercurial-server.1
else
for each in `ls /archives/mercurialnewbak |sort -n -r`
do
i=$(echo "$each" |awk -F. '{print $2}')
if [ ! -n "$i" ]; then
mv /archives/mercurialnewbak/mercurial-server /archives/mercurialnewbak/mercurial-server.1
else
let a=$i+1
mv /archives/mercurialnewbak/mercurial-server.$i /archives/mercurialnewbak/mercurial-server.$a
fi
done
fi
rsync -aP --link-dest=/archives/mercurialnewbak/mercurial-server.1 devgit1:/var/lib/mercurial-server /archives/mercurialnewbak
fi
阅读(1899) | 评论(0) | 转发(0) |