up vote 0 down vote favorite

Hi. 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

flag

67% accept rate

1 Answer

up vote 0 down vote accepted

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

link|flag

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.