当前位置: > Linux服务器 > ftp >

lftp自动上传备份shell脚本

时间:2014-11-29 20:46来源:linux.it.net.cn 作者:IT

lftp功能比较强大,各位站长其实可以利用它完成自己网站的备份,参考脚本如下
#!/bin/bash
BackPgName=”wordpress.date +%Y%m%d.sql”
echo “Begin to back up database wordpress to $BackPgName at date "+%h %d %H:%M:%S"”

cd /root/PgDBBack
#pg_dump database wordpress using –insert to avoid the char error
/usr/local/pgsql/bin/pg_dump  -U wordpress –insert wordpress | gzip > $BackPgName.gz

if [ $? -eq 0 ];then
echo “Back up succeed at date "+%h %d %H:%M:%S"”
else
echo “Back up failed and exit at date "+%h %d %H:%M:%S"”
exit -1
fi

echo “Begin to update database at date "+%h %d %H:%M:%S"”
lftp << EOF
open svn.wordpress.net
user idibao passwd
cd pgsqlback
put ${BackPgName}.gz
bye
EOF
mv $BackPgName.gz $BackPgName.Gz
echo “backup succeed at date "+%h %d %H:%M:%S"” > /tmp/pgsql_wordpress_bk.log

(责任编辑:IT)
------分隔线----------------------------