Skip to content

Instantly share code, notes, and snippets.

@wtser
Created April 18, 2015 01:22
Show Gist options
  • Save wtser/060f1610dba99878ddd6 to your computer and use it in GitHub Desktop.
Save wtser/060f1610dba99878ddd6 to your computer and use it in GitHub Desktop.
网站备份 Shell 脚本
#!/bin/sh
function backup(){
cd /var/www/
for siteName in $*
do
echo "打包 "$siteName
tar zcvf $siteName".tar.gz" $siteName"/"
# 远程拷贝
echo "正在发送到备份服务器"
scp $siteName".tar.gz" root@1.2.3.4:/var/www/
rm $siteName".tar.gz"
done
echo "网站传输完成"
}
backup 'site1.cn' 'site2.com'
# 恢复数据库
echo "正在恢复网站"
ssh root@1.2.3.4 "bash /var/tmp/website_restore.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment