HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Developers' Forum (http://www.howtoforge.com/forums/forumdisplay.php?f=18)
-   -   Large domain backups to browser (http://www.howtoforge.com/forums/showthread.php?t=36277)

pat 11th June 2009 11:49

Large domain backups to browser
 
Here are a couple of suggestions to changes to the backup routine. The first one is a pure cosmetical change and makes sure the hostname is part of the resulting filename. The second one is a little more interesting and makes sure we are not limited by available RAM when choosing output to browser rather than via FTP.

Cheers,
Pat


Code:

--- backup.php.orig    2009-05-20 19:33:53.000000000 +0200
+++ backup.php  2009-05-20 19:33:45.000000000 +0200
@@ -58,7 +58,7 @@
 if(strlen($ftp_user) < 1 and $transfer == 'ftp') $go_api->errorMessage($go_api->lng("Sie haben keinen FTP Benutzernamen angegeben."));

 // Erstelle Namen für Backup Datei
-$backup_file_name = "backup_".date("Y_m_d",time()).".zip";
+$backup_file_name = exec("hostname") . "-backup_".date("Y_m_d",time()).".zip";

 // bestimme Web-Pfad
 $server = $go_api->db->queryOneRecord("SELECT * from isp_server");
@@ -154,7 +154,7 @@
                header("Content-Length: ".filesize($tgz_name));

        // gebe Daten aus
-        echo file_get_contents($tgz_name);
+        readfile($tgz_name);

        // lösche temp Verzeichnis
        if($tmp_dir != "" and stristr($tmp_dir,"/home/admispconfig/ispconfig/temp") and !stristr($tmp_dir,"../")) exec("rm -rf $tmp_dir");


hairydog2 10th August 2009 12:56

Which backup.php is this?There seem to be three files of that name.

falko 2nd September 2009 16:28

Quote:

Originally Posted by pat (Post 193399)
Here are a couple of suggestions to changes to the backup routine. The first one is a pure cosmetical change and makes sure the hostname is part of the resulting filename. The second one is a little more interesting and makes sure we are not limited by available RAM when choosing output to browser rather than via FTP.

Cheers,
Pat


Code:

--- backup.php.orig    2009-05-20 19:33:53.000000000 +0200
+++ backup.php  2009-05-20 19:33:45.000000000 +0200
@@ -58,7 +58,7 @@
 if(strlen($ftp_user) < 1 and $transfer == 'ftp') $go_api->errorMessage($go_api->lng("Sie haben keinen FTP Benutzernamen angegeben."));

 // Erstelle Namen für Backup Datei
-$backup_file_name = "backup_".date("Y_m_d",time()).".zip";
+$backup_file_name = exec("hostname") . "-backup_".date("Y_m_d",time()).".zip";

 // bestimme Web-Pfad
 $server = $go_api->db->queryOneRecord("SELECT * from isp_server");
@@ -154,7 +154,7 @@
                header("Content-Length: ".filesize($tgz_name));

        // gebe Daten aus
-        echo file_get_contents($tgz_name);
+        readfile($tgz_name);

        // lösche temp Verzeichnis
        if($tmp_dir != "" and stristr($tmp_dir,"/home/admispconfig/ispconfig/temp") and !stristr($tmp_dir,"../")) exec("rm -rf $tmp_dir");


I've just implemented this. :)


All times are GMT +2. The time now is 02:46.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.