Web site backup in PHP?(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中的网站备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP中的网站备份?


基础教程推荐
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01