Chris81
Chris81

Reputation: 446

MySQLdump in php, I need it to dump in a specific directory

I run a script in one of my php files that dumps a specific database which works fine, but it puts the created file in the directory where the scripts is called. How can I make it to store the file in a specific directory? (e.g /blahblah/backups)

Here's the code (the connection code is not included but you get the idea)

system("mysqldump -h $pdb_server -u $pdb_user -p$pdb_pwd $pdb_name > $backupfile");

could I just add

/path/to/output/$backupfile

Upvotes: 1

Views: 2161

Answers (1)

René Höhle
René Höhle

Reputation: 27305

Put the Path before the command:

system("cd /path/to/output/$backupfile; mysqldump -h $pdb_server -u $pdb_user -p$pdb_pwd $pdb_name > $backupfile");

or

system("mysqldump -h $pdb_server -u $pdb_user -p$pdb_pwd $pdb_name > /path/to/output/$backupfile");

Upvotes: 3

Related Questions