php - MySQL: mysqldump to generate database backup -
i have had written next snippet generates mysql
database dump , saves on server:
public function save_db_backup() { $dbuser=$this->db->username; $dbpasswd=$this->db->password; $database=$this->db->database; $filename = $database . "-" . date("y-m-d_h-i-s") . ".sql.gz"; $save_path = $_server['document_root'] . '/application/assets/db_backups/' . $filename; $cmd = "mysqldump -u $dbuser --password=$dbpasswd $database | gzip --best > " . $save_path; exec( $cmd ); }
it has been working fine on other server. after moving site new server, has stopped working i.e. database backup file not beingness saved @ path specified. also, have checked exec
is enabled on server plus directory readable , writeable:
is_readable($_server['document_root'] . '/application/assets/db_backups/') // true is_writable($_server['document_root'] . '/application/assets/db_backups/') // true
i have checked , database credentials alright. have tried path mysqldump
, didn't work either:
$cmd = "/usr/bin/mysqldump -u $dbuser --password=$dbpasswd $database | gzip --best > " . $save_path;
what problem there perchance be?
you should check user launches command, , if dir readable , writeable user. if launching php script, it's probable cause.
php mysql mysqldump
No comments:
Post a Comment