ssh自动备份主机文件的脚本
程序员文章站
2023-02-18 21:11:51
复制代码 代码如下: #!/bin/bash cd /home/backup/ echo "---" echo "delete start:"$(date +'%y%m%d...
复制代码 代码如下:
#!/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 "^_^"
然后添加个每日任务就可以了。