hey,
ive created a database backup script which is working fine the way it works now.. the only problem is that the backup function is returning a database backup string. so all the content of the database in a string.. that isnt a big problem when you have a small database but it will get a problem when you have a 10MB db backup.. and that would be the raw .sql file. now to fix that issue i want to compress the string using zlib..
this is the code that i use to create the raw .sql file send it as a download to the user:
// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
$test = new backupdb;
$test->db_name = 'magedb';
$filename = "MageDB_db_backup_" . time() . ".sql";
//header('Content-Type: text/html; charset=utf-8');
//header('Content-Type: text/plain');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/force-download');
//header('Content-Type: text/plain'); // plain text file
echo $test->structure_dbbackup();
exit();
but that`s UNCOMPRESSED.. what do i need to change to make it compressed insize a .gz file?
i was thinking of this:
// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
$test = new backupdb;
$test->db_name = 'magedb';
$filename = "MageDB_db_backup_" . time() . ".sql.gz";
//header('Content-Type: text/html; charset=utf-8');
//header('Content-Type: text/plain');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/force-download');
//header('Content-Type: text/plain'); // plain text file
echo gzcompress($test->structure_dbbackup(), 9);
exit();
but that isnt working.. the file is being send to me.. and i can download it however i cant open the compressed file.. so i must have made a mistake somewhere.. i just can`t find where.
and i dont want the sql file to be stored on the server in a folder, than create a .gz file and than download that because thats higly insecure.. if someone is bored and tries to find out where the files are stored he could find the location of the database backups (with usernames and (md5 encrypted) passwords).. so the file can`t be stored on the server!!
anyone with some idea`s?
thanx.