有人知道一个干净的基于 PHP 的解决方案,可以使用 FTP 备份远程网站吗?
Does anybody know a clean PHP-based solution that can backup remote web sites using FTP?
必备:
会很好:
我需要它基于 PHP,因为它将用于不允许使用标准 GNU/Linux 工具的共享主机包.
I need this to be PHP based because it's going to be used on shared hosting packages that do not allow usage of the standard GNU/Linux tools.
我之前在一个 cron 作业 PHP 脚本中做过类似的事情.不确定这是否是最好的方法,但它确实有效.
I have done something like this in a cron job PHP script before. Not sure if it is the best way, but it certainly works.
$backup_file = '/home/example/sql_backup/mo_'.date('Y-m-d').'.sql.gz';
$command = '/usr/bin/mysqldump -c -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASS.' --default-character-set=latin1 -N '.DB_NAME.' | gzip > '.$backup_file;
exec($command);
然后你可以执行一个 sftp 到远程服务器.
You could then exec an sftp to the remote server.
您可以类似地使用 exec() 和 linux 压缩来处理文件夹.
You could do the file folders similarly using exec() and linux zipping.
这篇关于PHP中的网站备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!