复制代码 代码如下:
#!/bin/bash
cd /home/backup/
echo "---"
echo "delete start:"$(date +'%Y%m%d_%X')
echo " delete..."$(date -d -5day +"%Y%m%d_%H%M")
rm -rf Web_$(date -d -6day +"%Y%m%d")*
echo "delete end:"$(date +'%Y%m%d_%X')
echo "---"
echo "backup start:"$(date +'%Y%m%d_%X')
cp -R /home/www/ Web_$(date +"%Y%m%d_%H%M")
echo "backup end:"$(date +'%Y%m%d_%X')
echo "---"
echo "^_^"
然后添加个每日任务就可以了。
#!/bin/bash
cd /home/backup/
echo "---"
echo "delete start:"$(date +'%Y%m%d_%X')
echo " delete..."$(date -d -5day +"%Y%m%d_%H%M")
rm -rf Web_$(date -d -6day +"%Y%m%d")*
echo "delete end:"$(date +'%Y%m%d_%X')
echo "---"
echo "backup start:"$(date +'%Y%m%d_%X')
cp -R /home/www/ Web_$(date +"%Y%m%d_%H%M")
echo "backup end:"$(date +'%Y%m%d_%X')
echo "---"
echo "^_^"
然后添加个每日任务就可以了。