站长资源服务器

ssh自动备份主机文件的脚本

整理:jimmy2024/12/29浏览2
简介复制代码 代码如下: #!/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 We
复制代码 代码如下:
#!/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 "^_^"

然后添加个每日任务就可以了。