matd Posted April 26, 2003 Share Posted April 26, 2003 Hi, I\'d like to provide the administrators for some of the php / mysql websites i\'ve created recently with an option like that found in PhpMyAdmin, whereby they can click \'Backup the Database\' and it will dump the entire database into a gzip file and prompt them where they\'d like to save the file to etc... Does anyone know how this can be done? I know PhpMyAdmin creates the dump in the page tbl_dump.php Does anyone have a small sample of code that does the same thing? I know the answers are in tbl_dump.php somewhere but theres a lot of code there and a lot of shared values etc.... Any help greatly appreciated :-) Quote Link to comment https://forums.phpfreaks.com/topic/403-providing-a-site-backup-export-feature-like-in-phpmyadmin/ Share on other sites More sharing options...
phpfreak Posted April 27, 2003 Share Posted April 27, 2003 You could use this file: http://www.phpfreaks.com/script/view/11.php Quote Link to comment https://forums.phpfreaks.com/topic/403-providing-a-site-backup-export-feature-like-in-phpmyadmin/#findComment-1353 Share on other sites More sharing options...
matd Posted April 28, 2003 Author Share Posted April 28, 2003 hi phpfreak, I\'m trying out a custom version of that script as i want the user to be prompted to save the file when they click a link rather than display, e-mail or ftp the backup to them.. I\'ve seen some other articles on this so i\'ve tried to tack it all together and this is what i have come up with so far :- <?php include(\"../../config/config_sql.php\"); $export_filename = \"mybackup.gz\"; $export_dir = \"/home/matd/public_html/backup\"; $filename = \"$export_dir/$export_filename\"; $dump_buffer = ($filename); passthru(\"mysqldump --opt -h$server -u$user -p$password $database | gzip >$filename\"); $mime_type = \'application/x-gzip\'; $now = gmdate(\'D, d M Y H:i:s\') . \' GMT\'; header(\'Content-Type: \' . $mime_type); header(\'Expires: \' . $now); header(\'Content-Disposition: inline; filename=\"\'. $export_filename . \'\"\'); header(\'Cache-Control: must-revalidate, post-check=0, pre-check=0\'); header(\'Pragma: public\'); echo $dump_buffer; ?> This does prompt me to save the file but the file is always empty so i\'m half way there! ;-) Any ideas why the file would be empty? it seems like the passthru isn\'t working but all the required variables have been set correctly and the export feature using phpmyadmin works on the same machine... Any help greatly appreciated :-) Quote Link to comment https://forums.phpfreaks.com/topic/403-providing-a-site-backup-export-feature-like-in-phpmyadmin/#findComment-1359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.