Created
April 18, 2015 01:22
-
-
Save wtser/060f1610dba99878ddd6 to your computer and use it in GitHub Desktop.
网站备份 Shell 脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function backup(){ | |
cd /var/www/ | |
for siteName in $* | |
do | |
echo "打包 "$siteName | |
tar zcvf $siteName".tar.gz" $siteName"/" | |
# 远程拷贝 | |
echo "正在发送到备份服务器" | |
scp $siteName".tar.gz" [email protected]:/var/www/ | |
rm $siteName".tar.gz" | |
done | |
echo "网站传输完成" | |
} | |
backup 'site1.cn' 'site2.com' | |
# 恢复数据库 | |
echo "正在恢复网站" | |
ssh [email protected] "bash /var/tmp/website_restore.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment