PHP中的网站备份? [英] Web site backup in PHP?

查看:37
本文介绍了PHP中的网站备份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道一个干净的基于 PHP 的解决方案,可以使用 FTP 备份远程网站吗?

Does anybody know a clean PHP-based solution that can backup remote web sites using FTP?

必备:

  • 递归 FTP 备份
  • 可以运行 cron 作业
  • 易于配置(轻松添加多个站点)
  • 备份文件的本地存储就足够了

会很好:

  • 备份的网站存储为 zip 文件
  • 管理事务的好界面
  • 在备份成功或失败时提供通知
  • 是否进行增量备份
  • 是否备份 MySQL 数据库

我需要它基于 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中的网站备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆