PHP postgres 备份
我正在尝试制作一个 Postgres PHP 备份脚本。我已经下载了一个命令行,如下所示:
#!/bin/bash
find /home/russell/pg_bkp -type f -mtime +7 -exec rm {} \;
time=`date +%Y-%m-%d`; # date in reverse so that lastest date appears last in the list of backup files.
PGPASSWORD=****** pg_dump -i -h localhost -p 5432 -U postgres -F c -b -v -f "/home/russell/pg_bkp/$time.backup" ah3
How can I Implement this in PHP?这创建的扩展名是.backup。它效果很好并且已经使用了很多次。数据很完美,但从我的网站内部进行会更好。谢谢
I am trying to make a Postgres PHP backup script. I have downloaded one for the command line which looks like this:
#!/bin/bash
find /home/russell/pg_bkp -type f -mtime +7 -exec rm {} \;
time=`date +%Y-%m-%d`; # date in reverse so that lastest date appears last in the list of backup files.
PGPASSWORD=****** pg_dump -i -h localhost -p 5432 -U postgres -F c -b -v -f "/home/russell/pg_bkp/$time.backup" ah3
How can I implement this in PHP? The extension that this creates is .backup. It works great and have used it many times. the data is perfect, but doing it from inside my website would be better. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请更好地格式化代码。
对于您的问题,您可以将这些命令保存在文件中,然后通过 exec 或 passthru。
在 php 中,你甚至可以用特殊的撇号 ` 编写命令,它就会被执行。
只需确保 PHP 服务有运行该脚本的权限
Please, format better the code.
For your question, you can save those command in a file, and then call it throught php via exec or passthru.
In php, you can even write the command with the special apostrophes, `, and it will be executed.
Just make sure the PHP service has the permission to run that script