网站远程备份方法
1.手动备份迁移
先打包
cd /home/ && tar cvf web_$(date +"%Y%m%d%H%M%S").tar web
传输到其他VPS
apt install -y sshpass
cd /home/ && ls -t /home/*.tar | head -1 | xargs -I {} sshpass -p 123456 scp -P 22 {} root@0.0.0.0:/home/
只保留3个压缩包
cd /home/ && ls -t /home/*.tar | tail -n +4 | xargs -I {} rm {}
远端机器解压
tar -xf web.tar
2.自动备份迁移
下载sh脚本
apt update -y && apt install -y wget sudo
cd /home
wget beifen.sh https://raw.githubusercontent.com/kejilion/sh/main/beifen.sh
chmod +x beifen.sh
nano beifen.sh
运行sh脚本
./beifen.sh
定时任务
(crontab -l ; echo "0 2 * * 1 /home/beifen.sh") | crontab -


评论
发表评论