Jump to content
Sign in to follow this  
bobg7

OSC 2.2MS2 System Backup

Recommended Posts

Currently developing my first contribution for OSC called: :D

 

OSC System Backup Beta

 

From Admin>Tools you will now be able to do a complete backup of your entire website into a compressed tarball to FTP down to your PC. And if you do a Database Backup from Admin>Tools first, this will also add it to the System Backup.

 

From what I have been told some webhosts don't allow for passthru to be used on there servers, check with your webhost before installing.

 

Installation is simple, 1 file to upload, 1 folder and 4 edits to make, instructions are included.

 

I don't think I will be missing anything :-" but if I am, please let me know and I'll get on it as quick as I can.

 

Remember, BACK UP YOUR FILES BEFORE MAKING ANY CHANGES.

 

As soon as I have it ready and added to the contributions, I'll add a link here.

 

Good Luck,

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

You will be able to find the contribution at OSC System Backup BETA

 

Good luck.

 

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites
Installed it, no errors but when I activate it, it says everything ok but I don't see the file in the system_backup folder.

 

Please post your sysbackup.php so I can take a look at it.

 

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites
A little cheeky, but. . . . Any chance of supporting other compression formats? :thumbsup:

 

Not sure, I hacked this out of another larger piece of code and modified it to work.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites
Installed it, no errors but when I activate it, it says everything ok but I don't see the file in the system_backup folder.

Try putting a copy of the abspath.php into the system_backup directory and point your browser to it then compare the output from that to what you have in the sysbackup.php, if different, modify the path to your system_backup directory.

 

Let us know if it works.

 

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

Great peace of software, simple but very useful. Thanks a lot. I want to share the code for backup the whole database. There is a line where you can configure the maximum execution time for this script (Most times the only way to get a backup from a big database).

 

Maybe someone wants to make one big script for the whole backup process.

 

To define the database use this lines in the script:

 

  if(file_exists($secu_config))
 {
	 include ($secu_config);
	 $ck = "checked";
 }
 else
 {
	 $dbhost = "localhost";
	 $dbbase = "dreaxteam";
	 $dbuser = "root";
	 $dbpass = "";
	 $ck = "";

 

or define it in a extra file called:

 

yoursecretfile_here.inc.php

 

<?
$dbhost = "databasehost";
$dbbase = "databasename";
$dbuser = "user";
$dbpass = "password";
$savmode = "2";
$opt = "1";
$phpext = "";
?>

 

than create a file called: backup.php and save it in a extra backup directory like:

admin/backup/backup.php

 

<?
/* Minor changes by Stefan Fritsche (www.klosterbrauerei.com) 01.01.2005 */
/* German translation by Christian Mai (rubev@email.ro) 12.12.2002 */


/*
  Speicherung der Verbindungsparameter
  
Modify below the name of the file for saving the connection parameters after obtaining the data.
It is strongly recommended that you include the extension ".php" or ".php3" to render the file unreadable 
from the Internet.

*/

$secu_config = "yoursecretfile_here.inc.php";


//Geben Sie hier den Wert ein, nach dem das Script automatisch neu starten soll.
//Damit wird der n?chste Teil des Backup bekonnen.
//Define = die maximale Ausf?hrungszeit des Scriptes in Sekunden.
define("MAX_EXECUTION_TIME",90);


/*
 NE PLUS MODIFIER LE FICHIER EN DESSOUS DE CETTE LIGNE (Sauf si vous savez ce que vous faites;) )
 DO NOT MODIFY THE FILE BELOW THIS LINE (unless you know what you're doing;)).
 ?ndern Sie ab hier bitte nichts in den folgenden Zeilen, es sei denn , Sie wissen, was Sie da gerade tun;)).
*/

//StartTime 
$m_iStartTime = time();

if (isset($lasttable)) {
 Header('Cache-Control: no-cache');
 Header('Pragma: no-cache');
}

/* Header */

if ($go=="save") {
  
 $frmProgressHtml= "
    <FORM action=\"\" method=post id=frmProgress name=frmProgress>
     <P><INPUT id=txtProgress name=txtProgress  size=60></P>
   </FORM>
 "; 
}
else {
    $frmProgressHtml = "";
}



echo "
<html>
<head>
<title>Dump Script from Klosterbrauerei(dot)com</title>
<style>
.link:hover {TEXT-DECORATION: underline}
.link {font: italic 8pt; font-family: verdana; TEXT-DECORATION: none; color: #000066}
.texte {font: 8pt; font-family: verdana;}
</style>
</head>
<body bgcolor=\"#7087A7\">
<center>
<br><br>
$frmProgressHtml
<br>
<table width=820 cellpadding=\"0\" cellspacing=\"0\" align=center>
<col width=1 bgcolor=\"#2D7DA7\">
<col width=800>
<col width=1 bgcolor=\"#2D7DA7\">
<tr>
 <td></td>
 <td bgcolor=\"#2D7DA7\" align=\"center\" style=\"font: bold 14px; font-family: verdana;\">
 Dump Script From www.klosterbrauerei(dot)com  <br>
 </td>
 <td></td>
</tr>
<tr>
 <td></td>
<td bgcolor=\"#566984\" align=left class=texte>
   <br>
";



/* Footer */ 

$footer = "<br>
	 <center><a href=\"$PHP_SELF\" target=\"_self\" class=link> - Nochmal beginnen - </a><br></center>
	 <br>
<center><a href=\"http://www.shop.klosterbrauerei.com\" target=\"_blank\" class=link> - If you like this peace of software come to - </a><br></center>
<center><a href=\"http://www.shop.klosterbrauerei.com\" target=\"_blank\" class=link> - www.shop.klosterbrauerei.com and order your monastery beer - </a><br></center>
 </td>
 <td></td>
</tr>
<tr>
 <td height=1 colspan=3></td>
</tr>
</table>
<br>
</body>
</html>
";

//module file pointer
define("FILE_TYPE_GZIP",1);
define("FILE_TYPE_TEXT",0);

$m_fp=0;
$m_filetype=FILE_TYPE_TEXT;

// file functions
function open_file($sFileName,$bAppend) {

global $m_fp,$m_filetype;

       $sMode="";

           if (FILE_TYPE_GZIP==$m_filetype)
	 {
      if ($bAppend) {
      $sMode= "ab9";
   }
   else {
      $sMode= "wb9";
   }
   
   $m_fp = gzopen($sFileName,$sMode);
	 }
	 else
	 {
      if ($bAppend) {
      $sMode= "a";
   }
   else {
      $sMode= "w";
   }
   $m_fp = fopen ($sFileName,$sMode);
	 }
}

function write_file($sdata){

 global $m_fp,$m_filetype;
 

 if (FILE_TYPE_GZIP==$m_filetype){
  	 gzwrite ($m_fp,$sdata);
 }
 else{
  	 fwrite ($m_fp,$sdata);
 }

}

function close_file(){

global $m_fp,$m_filetype;

if (FILE_TYPE_GZIP==$m_filetype)
	 {
   gzclose ($m_fp);
	 }
	 else
	 {
   fclose ($m_fp);
	 }
}

// manage states  functions 
function next_page_form($iLastTable,$iLastRow) {

 $aGetPostVars=array();
 
 //get vars 
 $aVars = $GLOBALS["HTTP_GET_VARS"]; 
  while(list($key, $value) = each($aVars)) 
  { 
     //echo "$key = $value<br>"; 
     $aGetPostVars[$key]=$value;
  }
 
 //post vars 
 $aVars = $GLOBALS["HTTP_POST_VARS"]; 
 while(list($key, $value) = each($aVars)) 
 { 
     //echo "$key = $value<br>"; 
     $aGetPostVars[$key]=$value;
 }
 
 $sForm = "<form id='frmNextPage' name='frmNextPage' method='post' action='" . $GLOBALS["PHP_SELF"] ."'>\n";
 $iNumVars=0;
 $iNumOfPoints=0;
 
 $aGetPostVars["lasttable"]=$iLastTable;
 $aGetPostVars["lastrow"]=$iLastRow;
   
 while(list($key, $value) = each($aGetPostVars)) 
 { 
    $iNumVars++;
 
 if (is_array($value)){
  foreach($value as $k => $v) {
      //echo "\$" . $key . "[$k] => $v <br>";
   $sForm .= "<INPUT type='hidden' name='".$key."[".$k."]' value='".htmlentities($v)."'>\n";
  }
 }
    else {
    
    //echo "$key = $value<br>"; 
 $sForm .= "<INPUT type='hidden' name='$key' value='".htmlentities($value)."'>\n";
 }
 }
 
       $sForm .= "<button type='submit'>Resume Dump</button>\n";
       $sForm .= "</FORM>\n";
 
 return  $sForm;
}

function ProgressUpdate($sText) {

  $sText = htmlentities($sText);
  echo "
   \n
  <script language=\"javascript\">
  <!--
  document.frmProgress.txtProgress.value = \"$sText\";
  //-->
  </script>
  \n";
  flush();
}  

/*
if (!minimum_version("4.1.1"))
   echo "Minimum version not met.";
else
   echo "You're in!";
*/

function minimum_version( $vercheck ) {
   $minver = explode(".", $vercheck);
   $curver = explode(".", phpversion());

if (  ($curver[0] < $minver[0])
     || (($curver[0] == $minver[0]) && ($curver[1] < $minver[1]))
     || (($curver[0] == $minver[0]) && ($curver[1] == $minver[1]) && ($curver[2][0] < $minver[2][0])))
       return false;
   else
       return true;	
 
} 


/*  Funktion zum Speichern als SQL */
/* Speichern als SQL Script */
        
function sav_sql($dbhost,$dbuser,$dbpass,$dbbase,$table,$fich,$sv_s,$sv_d,$iFirstRow , $iTable , $bAddDropTable)
{
//global $data;
global $m_iStartTime;

$sProgressText = "";

$sNextPageUrl="";
 
$connex = mysql_connect($dbhost,$dbuser,$dbpass);
$list_champs = mysql_list_fields($dbbase,$table);


$sProgressText =  "Saving Table: $table elapsed:" . (time() - $m_iStartTime) . "(s)";
   
echo $sProgressText . "<br>";
ProgressUpdate($sProgressText);

$data ="";

if ($sv_s)
{
    mysql_query('SET SQL_QUOTE_SHOW_CREATE = 0',$connex);
    $result = mysql_query("SHOW CREATE TABLE $table",$connex);
       $tmpres        = mysql_fetch_array($result);
       $data .= str_replace("\n", " ", $tmpres[1]) . ";\n";
    if ($bAddDropTable) {	
	 $data = "\n\nDROP TABLE IF EXISTS $table;\n" . $data;	
 }
   }

   

write_file($data);

$data ="";

$query2 = "SELECT * FROM $table";
$result2 = mysql_query($query2,$connex);
$nbchamps = mysql_num_fields($result2);
   
$iRowsSaved = 0;
$afield_num = array();

$sFieldContent = "";
$sSQLField="";

//verify numeric fields 
for ($j=0;$j<$nbchamps;$j++) {
    
 $type = mysql_field_type($result2, $j);
 
 if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' ||
                   $type == 'bigint'  ||$type == 'timestamp') {
             $afield_num[$j] = TRUE;
       } else {
             $afield_num[$j] = FALSE;
       }
    
 //echo $type . " " . $afield_num[$j] . " <br>"; 	 
 unset($type);
}


$bFastReplace = minimum_version("4.0.5");

$aSearchSlashes = array('\\',"//");  
$aReplaceSlashes = array('\\\\',"\/\/");	
    	 
$aSearch = array('\'',"\"",chr(10),chr(13),"\t","\x00","\x1a"); 	 
$aReplace = array('\\\'',"\\\"","\\n","\\r","\\t","\\0","\\Z");

//echo "Fast Replace $bFastReplace <br>";

if ($sv_d)
{
    //skip saved records 
 while($iRowsSaved<$iFirstRow)
 {
   if ($row = mysql_fetch_row($result2)){
      $iRowsSaved++;
   }
   else {
      break;
   } 
      
 }
 
 while($row = mysql_fetch_row($result2))
 {
         //save field 
         $data ="";
    	 $data .= "INSERT INTO $table VALUES(";
    	 $c=0;
    	 
   while ($c < $nbchamps)
    	 {
          $sSQLField = "";
       
       if ($c != 0)
       {
      	 $data .= ",";
       }
                  	 
  	 if (!isset($row[$c])) {
                       $sSQLField     = 'NULL';
                   } else if ($row[$c] == '0' || $row[$c] != '') {
                       // a number
                       if ($afield_num[$c]) {
                           $sSQLField = $row[$c];
                       }
                       // a string
                       else {
     
         $sFieldContent =$row[$c];
          	 
    	 if ($bFastReplace) {
          $sFieldContent = str_replace ($aSearchSlashes,$aReplaceSlashes,$sFieldContent);
       $sFieldContent = str_replace ($aSearch,$aReplace,$sFieldContent);
    	 }
    	 else {           	 
        	 $sFieldContent = str_replace ('\\','\\\\',$sFieldContent);
              	 $sFieldContent = str_replace("//","\/\/",$sFieldContent);
              	 $sFieldContent = str_replace('\'', '\\\'', $sFieldContent);
              	 $sFieldContent = str_replace ("\"","\\\"",$sFieldContent);
                   $sFieldContent = str_replace (chr(10),"\\n",$sFieldContent);
                   $sFieldContent = str_replace (chr(13),"\\r",$sFieldContent);
                   $sFieldContent = str_replace ("\t","\\t",$sFieldContent);
                   $sFieldContent = str_replace ( "\x00","\\0",$sFieldContent);
                     $sFieldContent = str_replace ( "\x1a","\\Z",$sFieldContent);
                          }
            
        $sSQLField = "'" . $sFieldContent . "'";
                       }
                   } else {
                       $sSQLField     = "''";
                   } // end if
          	 
       $data .= $sSQLField;
       
       $c++;
    	 } // end while ($c < $nbchamps)
    	 
    	 $data .= ");\n";
	 
    	 write_file($data);
         $iRowsSaved++;
   
   //verify timeout
   if ((time() - $m_iStartTime)>MAX_EXECUTION_TIME) {
      $sNextPageUrl = next_page_form($iTable,$iRowsSaved);
      $sProgressText= "Table:$table Records Saved:" . ($iRowsSaved) . " elapsed:" . (time() - $m_iStartTime) . "(s)";
      echo "<br>$sProgressText<br>";
      ProgressUpdate($sProgressText);
      break;
   }
    	 
   
    	 if ((($iRowsSaved) % 200)==0) {
       $sProgressText = "Table:$table Records Saved:" . ($iRowsSaved) . " elapsed:" . (time() - $m_iStartTime) . "(s)";
  	 echo $sProgressText . "<br>";
                   ProgressUpdate($sProgressText);
       
    	 } 
 } //while($row = mysql_fetch_row($result2))
} // if ($sv_d)
   
mysql_free_result($result2);
mysql_close();

return $sNextPageUrl;
}

switch ($go)
{
/* Affichage Principal */
/* Main Page */

case "":

 if(file_exists($secu_config))
 {
	 include ($secu_config);
	 $ck = "checked";
 }
 else
 {
	 $dbhost = "localhost";
	 $dbbase = "dreaxteam";
	 $dbuser = "root";
	 $dbpass = "";
	 $ck = "";
 }
 echo "
 <form action=\"\" method=\"post\">
 <input type=\"hidden\" name=\"go\" value=\"connect\">
 <table border=0 align=center>
	 <col>
	 <col align=left>
	 <tr>
   <td colspan=2 align=center style=\"font: bold 9pt; font-family: verdana;\">Konfiguration der Datenbank -Verbindung<br><br></td>
	 </tr>
	 <tr>
   <td class=texte>Datenbank Host ( mysql / localhost )</td>
   <td><INPUT TYPE=\"TEXT\" NAME=\"dbhost\" SIZE=\"30\" VALUE=\"$dbhost\"></td>
	 </tr>
	 <tr>
   <td class=texte>Datenbank Name</td>
   <td><INPUT TYPE=\"TEXT\" NAME=\"dbbase\" SIZE=\"30\" VALUE=\"$dbbase\"></td>
	 </tr>
	 <tr>
   <td class=texte>Datenbank Benutzername</td>
   <td><INPUT TYPE=\"TEXT\" NAME=\"dbuser\" SIZE=\"30\" VALUE=\"$dbuser\"></td>
	 </tr>
	 <tr>
   <td class=texte>Datenbank Benutzer Passwort</td>
   <td><INPUT TYPE=\"Password\" NAME=\"dbpass\" SIZE=\"30\" VALUE=\"$dbpass\"></td>
	 </tr>
 </table>
 
 <br>
 <center>
 <input type=\"checkbox\" name=\"secu\" value=\"1\" $ck> Oben eingegebe Verbindungsdaten speichern<br>
 <br><br>
 <input type=\"submit\" value=\" Verbinden \"></center>
 </form>
 <br><br>
 
	 </td>
	 <td></td>
 </tr>
 <tr>
	 <td height=1 colspan=3></td>
 </tr>
 </table>
 <br>
 <a href=\"http://\" class=link></a>";

break;

/* Fin Affichage Principal */
/* End Main Page */


/* Affichage Connecter */
/* Connection Page */

case "connect":

 /* V?rification des param?tres de connexion */
 /* Check connection parameters */
         
 if(!@mysql_connect($dbhost,$dbuser,$dbpass))
 {
	 echo "<br><center><font color=red><b>Die Verbindung zur MySQL Datenbank konnte nicht hergestellt werden.<br>Can not connect to database<br>Bitte ueberpruefen sie die Verbindungseinstellungen.<br>Please check Configuration details</b></font></center>\n$footer";
	 exit;
 }
 
 if(!@mysql_select_db($dbbase))
 {
	 echo "<br><center><font color=red><b>Die von Ihnen ausgewaehlt Datenbank existiert leider nicht.<br>Database does not exist<br>Bitte ueberpruefen Sie die Verbindungseinstellungen.<br>Plese check Configuration Details</b></font></center>\n$footer";
	 exit;
 }

 if ($secu == 1)
 {
	 if (!file_exists($secu_config))
	 {
   $fp = fopen($secu_config, "w");
   fputs($fp,"<?\n");
   fputs($fp,"\$dbhost = \"$dbhost\";\n");
   fputs($fp,"\$dbbase = \"$dbbase\";\n");
   fputs($fp,"\$dbuser = \"$dbuser\";\n");
   fputs($fp,"\$dbpass = \"$dbpass\";\n");
   fputs($fp,"?>");
   fclose($fp);
	 }
	 
	 include($secu_config);
	 
	 $s1 = "";
	 $s2 = "";
	 $s3 = "";
	 
	 $o1 = "";
	 $o2 = "";
	 $o3 = "";
	 
	 $p1 = "";
	 $p2 = "";
	 
	 $ck = "checked";
	 
	 switch($savmode)
	 {
   case ""  : $s1 = $ck; break;
   case "1" : $s1 = $ck; break;
   case "2" : $s2 = $ck; break;
   case "3" : $s3 = $ck; break;
	 }
	 
	 switch($opt)
	 {
   case ""  : $o1 = $ck; break;
   case "1" : $o1 = $ck; break;
   case "2" : $o2 = $ck; break;
   case "3" : $o3 = $ck; break;
	 }
	 
	 switch($phpext)
	 {
   case ""  : $p1 = $ck; break;
   case "3" : $p2 = $ck; break;
	 }
	 
 }
 else /* On utilise pas le fichier de sauvegarde //  If not using a save-config file */
 {
	 if (file_exists($secu_config))
	 {
   unlink($secu_config);
	 }
	 
	 $ck = "checked";
	 $s1 = $ck;
	 $o1 = $ck;
	 $p1 = $ck;
 }

 mysql_connect($dbhost,$dbuser,$dbpass);
 $tables = mysql_list_tables ($dbbase);
 $nb_tbl = mysql_num_rows ($tables);
 
   
 echo "
 <script language=\"javascript\">
 function checkall()
 {
	 var i = 0;
 
	 while (i < $nb_tbl)
	 {
   a = 'tbls[' + i + ']';
   document.formu.elements[a].checked = true;
   i = i+1;
	 }
 
 }

 function decheckall()
 {
	 var i = 0;
 
	 while (i < $nb_tbl)
	 {
   a = 'tbls[' + i + ']';
   document.formu.elements[a].checked = false;
   i = i+1;
	 }
 
 }
 <"."/script>
 <script LANGUAGE=\"Javascript1.2\">
 IE4 = (document.all) ? 1 : 0;
 NS4 = (document.layers) ? 1 : 0;
 VERSION4 = (IE4 | NS4) ? 1 : 0;
 if (!VERSION4) event = null;
 
 function BullGetOffset(obj, coord) {
	 var val = obj[\"offset\"+coord];
	 if (coord == \"Top\") val += obj.offsetHeight;
	 while ((obj = obj.offsetParent )!=null) {
   val += obj[\"offset\"+coord];
   if (obj.border && obj.border != 0) val++;
	 }
	 return val;
 }
 
 function BullDown () {
	 if (IE4) document.all.infobull.style.visibility = \"hidden\";
	 if (NS4) document.infobull.visibility = \"hidden\";
 }
 
 function BullOver (event,texte) {
	 if (!VERSION4) return;
 
	 var ptrObj, ptrLayer;
	 if (IE4) {
   ptrObj = event.srcElement;
   ptrLayer = document.all.infobull;
	 }
	 if (NS4) {
   ptrObj = event.target;
   ptrLayer = document.infobull;
	 }
 
	 if (!ptrObj.onmouseout) ptrObj.onmouseout = BullDown;
 
	 var str = '<DIV CLASS=\"infobullDIV\">'+texte+'</DIV>';
	 if (IE4) {
   ptrLayer.innerHTML = str;
   ptrLayer.style.top  = BullGetOffset (ptrObj,\"Top\") + 2;
   ptrLayer.style.left = BullGetOffset (ptrObj,\"Left\");
   ptrLayer.style.visibility = \"visible\";
	 }
	 if (NS4) {
   ptrLayer.document.write (str);
   ptrLayer.document.close ();
   ptrLayer.document.bgColor = \"yellow\";
   ptrLayer.top  = ptrObj.y + 20;
   ptrLayer.left = ptrObj.x;
   ptrLayer.visibility = \"show\";
	 }
 }
 // -->
 <"."/SCRIPT>
 <STYLE TYPE='text/css'>
 <!--
 #infobull {
	 position: absolute;
	 z-index: 1000;
	 top: 0px;
	 left: 0px;
	 width: 200px;
 }
 DIV.infobullDIV {
	 width: 200px;
	 padding: 2px;
	 background: yellow;
	 border: 1px solid black;
	 color: black;
	 font-family: Arial,Helvetica;
	 font-style: Normal;
	 font-weight: Normal;
	 font-size: 12px;
	 line-height: 14px;
 }
 -->
 <"."/STYLE>

 <center>
 <br>
 <b>Bitte auswaehlen, welche Tabellen gespeichert werden sollen</b>
 <form action=\"\" method=\"post\" name=formu>
 <input type=\"hidden\" name=\"go\" value=\"save\">
 <input type=\"hidden\" name=\"secu\" value=\"$secu\">
 <input type=\"hidden\" name=\"savmode\" value=\"$savmode\">
 <input type=\"hidden\" name=\"opt\" value=\"$opt\">
 <input type=\"hidden\" name=\"phpext\" value=\"$phpext\">
 <input type=\"hidden\" name=\"dbhost\" value=\"$dbhost\">
 <input type=\"hidden\" name=\"dbbase\" value=\"$dbbase\">
 <input type=\"hidden\" name=\"dbuser\" value=\"$dbuser\">
 <input type=\"hidden\" name=\"dbpass\" value=\"$dbpass\">
 <input type=\"hidden\" name=\"lasttable\" value=\"-1\">
 <input type=\"hidden\" name=\"lastrow\" value=\"-1\">
 <DIV ID=\"infobull\"></DIV>
 <table border=\"0\" width=\"600\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=texte>
 <col width=1 bgcolor=\"#2D7DA7\">
 <col width=30 align=center valign=center>
 <col width=1 bgcolor=\"#2D7DA7\">
 <col width=350>
 <col width=1 bgcolor=\"#2D7DA7\">
	 <tr>
   <td bgcolor=\"#2D7DA7\" colspan=5></td>
	 </tr>
	 <tr>
   <td></td>
   <td bgcolor=\"#336699\"><input type=\"checkbox\" name=\"selc\" alt=\"Select All\" onclick=\"if (document.formu.selc.checked==true){checkall();}else{decheckall();}\" onMouseover=\"BullOver(event,'Alle Tabellen auswaehlen')\"></td>
   <td></td>
   <td bgcolor=\"#336699\" align=center>Tabellen Name</td>
   <td></td>
	 </tr>
	 <tr>
   <td bgcolor=\"#2D7DA7\" colspan=5></td>
	 </tr>
 ";

 $i = 0;
 while ($i < mysql_num_rows ($tables))
 {
	 $coul = '#7D93B0';
	 if ($i % 2)
	 {
   $coul = '#6D86A7';
	 }
	 $tb_noms[$i] = mysql_tablename ($tables, $i);
	 echo "	<tr>
     <td></td>
     <td bgcolor=\"$coul\"><input type=\"checkbox\" name=\"tbls[$i]\" value=\"$tb_noms[$i]\"></td>
     <td></td>
     <td bgcolor=\"$coul\">   $tb_noms[$i]</td>
     <td></td>
  	 </tr>
  	 <tr>
     <td bgcolor=\"#2D7DA7\" colspan=5></td>
  	 </tr>";
	 $i++;
 }

 mysql_close();
 
 echo "
 </table>
 <br><br>
 <table align=center border=0>
	 <tr>
   <td align=left class=texte>
   <hr>
  	 <input type=\"radio\" checked name=\"savmode\" value=\"2\" $s2> Als SQL Datei speichern (*.<i>sql</i>)<br>
   <hr>
  	 <input type=\"radio\" name=\"opt\" value=\"1\" $o1>Struktur und Daten<br>
  	 <input type=\"radio\" name=\"opt\" value=\"2\" $o2>Nur Struktur <br>
  	 <input type=\"radio\" name=\"opt\" value=\"3\" $o3>Nur Daten <br><br>
  	 <input type=\"Checkbox\" name=\"chkdroptable\" checked value=\"1\"> Mit DROP TABLE 
   <hr>
  	 <input type=\"Checkbox\" name=\"gz\" value=\"1\"> Sende in Gzip.
   </td>
	 </tr>
 </table>
 <br><br>
 <input type=\"submit\" value=\" Save \">
 </form>
 </center>
 $footer";

break;

/* Fin Affichage Connecter */
/* End Connection Page */


/* Sauvegarde */
/* Saving Page */

case "save":

 if ($secu == 1)
 {
	 $fp = fopen($secu_config, "w");
	 fputs($fp,"<?\n");
	 fputs($fp,"\$dbhost = \"$dbhost\";\n");
	 fputs($fp,"\$dbbase = \"$dbbase\";\n");
	 fputs($fp,"\$dbuser = \"$dbuser\";\n");
	 fputs($fp,"\$dbpass = \"$dbpass\";\n");
	 fputs($fp,"\$savmode = \"$savmode\";\n");
	 fputs($fp,"\$opt = \"$opt\";\n");
	 fputs($fp,"\$phpext = \"$phpext\";\n");
	 fputs($fp,"?>");
	 fclose($fp);
 }

 if (!is_array($tbls))
 {
	 echo "<br><center><font color=red><b>Es wurden keine Tabellen zur Speicherung ausgewaehlt.<br>Bitte waehlen Sie mindestens eine Tabelle aus. :)</b></font></center>\n$footer";
	 exit;
 }


 /* Linearisation du tableau */
 
 $tbl = array();
 
 $tbl[] = reset($tbls);
 
 if (count($tbls) > 1)
 {
	 $a = true;
	 while ($a != false)
	 {
   $a = next($tbls);
   if ($a != false)
   {
  	 $tbl[] = $a;
   }
	 }
 }
 
 

	 
 if ($opt == 1)
 {
	 $sv_s = true;
	 $sv_d = true;
 }
 else if ($opt == 2)
 {
	 $sv_s = true;
	 $sv_d = false;
	 $fc   = "_struct";
 }
 else if ($opt == 3)
 {
	 $sv_s = false;
	 $sv_d = true;
	 $fc   = "_data";
 }
 else
 {
	 echo "<br><center><font color=red><b>Es ist ein interner Fehler aufgetreten. Haben Sie das Script vielleicht an einer falschen Stelle modifiziert?</b></font></center>\n$footer";
	 exit;
 }

 switch($savmode){


	 /* Sauvegarde Type SQL */
	 /* Saving as SQL script */
 
	 case "2":
   $fich = "dump_$dbbase" . $fc . ".sql";
   $i = 1;
   
   
   //save always with the same name 
   
   /*
   while (file_exists($fich))
   {
  	 $fich = "dump_$dbbase" . $fc . "_" . $i . ".sql";
  	 $i++;
   }
   */
   
   if (1==$gz) {
      $m_filetype=FILE_TYPE_GZIP;
      $fich= $fich . ".gz";
   }
   else {
      $m_filetype=FILE_TYPE_TEXT;
      $fich= $fich;
   }
   
   open_file($fich,($lasttable>=0));
   
   $data = "";
   $sNextUrl="";
   $lasttable=intval($lasttable);
   $lastrow=intval($lastrow);
   
   if ($lasttable<0) {
      $iFirstTable=0;
   }
   else { 
      $iFirstTable= $lasttable; 
   }
   
   $iFirstRow=$lastrow;
   
     
   //Save header 
   if ($lasttable<0) {
       $data = "";
       $data .= "##############################################\n";
  	 $data .= "# This is Modified Version of XT-DUMP v 0.6 ##\n";
  	 $data .= "#    Modified by lovesp@altavista.net       ##\n";	
     $data .= "#    Modified by lwww.klosterbrauerei.com       ##\n";  
       $data .= "##           Created by XT-Dump             ##\n";
       $data .= "##         http://dreaxteam.free.fr         ##\n";
       $data .= "##         http://www.klosterbrauerei.com         ##\n";
       $data .= "##############################################\n\n";
   
       write_file($data);
   }
   else {
       $data = "";
       $data .= "##         Next Part        ##\n"; 
  	 write_file($data);
   }
   
   
   $bSaveStruct=0;
   $bAddDropTable = (1==$chkdroptable);
         
   for ($i = $iFirstTable; $i < count($tbl);$i++)
   {
    	 
  	 if (($lasttable>=0) && ($i==$lasttable)) {
         $bSaveStruct = FALSE;
  	 } 
  	 else {
      $bSaveStruct = $sv_s;  
       }
    
       $sNextUrl = sav_sql($dbhost,$dbuser,$dbpass,$dbbase,$tbl[$i],$fich,$bSaveStruct,$sv_d,$iFirstRow,$i,$bAddDropTable);
       if (trim($sNextUrl)!=""){
      break;
  	 }
  	 else {
      $tblsv = $tblsv . "<b>" . $tbl[$i] . "</b> - ";
      $iFirstRow=-1; 
  	 }
   }

   close_file();  

      	 
   if (trim($sNextUrl)!=""){
       echo "<br>Die Erstellung des Dump ist nicht fehlgeschlagen, nur die maximale Ausf?hrungszeit des Scriptes wurde erreicht.
          <br> 
       Das Backup startet automatisch weiter. If nothing happend click the Button below
      ";
  	 
  	 echo "<br><br><center>$sNextUrl</center><br>\n";
      
       echo "
  	 
        <script LANGUAGE='JavaScript'>
     <!--
    	 function redirect () { setTimeout('go_now()',5000); }
    	 function go_now ()   { document.frmNextPage.submit(); }
         redirect();
     //-->
     </SCRIPT>	
         ";
                    
      ProgressUpdate("Bitte warten. Das Backup wird in 5 Sekunden weitergef?hrt.");
   }	
   else {     	 
       echo "
       <br>
       <center>
       Backup beendet. Eine Datei ist zum Download breit <a href=\"$fich\" class=link target=\"_blank\">\"$fich\"</a><br>
       </center>";
  	 ProgressUpdate("Backup fertig");
   }
   
   
   echo $footer;
   

	 break;
	 
	 /* End Saving as SQL script */
 }  

break;
/* End Saving */
}
/* End file */

?>

 

 

HTH

 

Stefan Fritsche

www.klosterbrauerei.com

Share this post


Link to post
Share on other sites

Kooyan, This looks great, and works fine apart from upon finishing the backup i get:

 

Fatal error: Maximum execution time of 60 seconds exceeded

 

I have modified the 'maximum execution time' and it seems to make no difference, the 'process' itself seems to complete but when it comes to create the sql file i get the above error.

 

If i just backup a small part of the database (that takes under 60 seconds) it works just fine, that in itself is excellent as backing up with phpmyadmin is a nitemare!

 

If you could shed any light on this it would be fantastic

Share this post


Link to post
Share on other sites

Hi folks, I'm trying to tweak thhe OSC System Backup a little and need some help with a piece of code. What I am attempting to do is add a link to the output page that displays the backup files you have in the system_backup directory so it can be selected and saved to your desktop.

 

The code:

<?php

function directory($result) { 

   

    $handle=opendir("./system_backup");

    while ($file = readdir($handle)) { 

    if ($file == "." || $file == "..") { } else { print "<a href=$file>$file</a><br>\n"; }

     

    } 

    closedir($handle); 

 

return $result; 

?> 

<b>Select the file you want to Download:</b>

<p>

<?php

echo directory($result); 

?>

 

The output:

Your System Backup is now complete! Select the file you want to Download:

 

bak_20050104_10-32-54.tar

 

Problem is, when you look at the link it creates it looks like this:

 

And it should be:

 

If anyone has any ideas how to get this to work, please let me know so I can get the contribution updated and more functional.

 

Thanks in advance,

 

Bob G.

Edited by bobg7

Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

@consoleplus

 

//Geben Sie hier den Wert ein, nach dem das Script automatisch neu starten soll.
//Damit wird der n?chste Teil des Backup bekonnen.
//Define = die maximale Ausf?hrungszeit des Scriptes in Sekunden.
define("MAX_EXECUTION_TIME",90);

 

Did you see that line? Here you define the maximum time execution.

 

Try:

 

//Geben Sie hier den Wert ein, nach dem das Script automatisch neu starten soll.
//Damit wird der n?chste Teil des Backup bekonnen.
//Define = die maximale Ausf?hrungszeit des Scriptes in Sekunden.
define("MAX_EXECUTION_TIME",30);

 

HTH

 

Stefan Fritsche

klosterbrauerei.com

Share this post


Link to post
Share on other sites

I am also getting the same problems as Misa.

 

I have installed the contrib I get the "Your System Backup is now complete! Remember to FTP the backup to your PC." but cant find any files in the system_backup folder.

Here is my sysbackup.php

<?php
        $backupdate = date("Ymd_H-i-s");
        //Backup date variable. Replace "Ymd" with
        //"Ymd_H-i-s" to include the time.

        $backupdir = "/home3/wendy/simplyfancydress-www/";
        //Change to the absolute path to your website
        
        $files = "*";
        //What file to backup? Use a * to backup all the files
        //inside the folder entered above.
        
        $backupto = "/home3/wendy/simplyfancydress-www/admin/system_backup";
        //Change to the absolute path to your /admin/system_backup directory

        $fileprefix = "bak";
        //This is the prefix that will be added before the date:
        //(bak_20040326.tar)
        //The underscore _ is added automatically

        $tararg = "-cf";
        //Here goes the tar arguments. I recommend -cf.
        //c is for compressing. f is for outputting
        //a file.

        $bz2arg = "-z9";
        //Here goes the bunzip2 arguments. I recommend -z9.
        //z is for creating a archive
        //and 9 is for max compression. z is always needed

//Call the function
backupsus();
        
function backupsus() {
      global $backupdate,$backupdir,$backupto,
      $fileprefix,$tararg,$files;
$backupsuscmd = "cd $backupdir;
   tar $tararg {$fileprefix}_{$backupdate}.tar $files;
   bunzip2 $bz2arg {$fileprefix}_{$backupdate}.tar;
   mv {$fileprefix}_{$backupdate}.tar $backupto";
  passthru ("$backupsuscmd");
}
echo "Your System Backup is now complete! Remember to FTP the backup to your PC.";
?>

Share this post


Link to post
Share on other sites

It should be here: www.your-site.com/admin/system_backup

 

HTH

Stefan Fritsche

klosterbrauerei.com

Edited by kooyan

Share this post


Link to post
Share on other sites
Installed it, no errors but when I activate it, it says everything ok but I don't see the file in the system_backup folder.

I experienced the same with several other compression scripts. If something goes wrong with the compression/script (the compression script itself isn't found? or there is no permission to execute one of the used commands? or??), no error is printed. The script says ok, but there's no file.

 

Haven't tried the contribution myself yet, sounds very interesting though! Hope to try soon.

Edited by PandA.nl

Please do not PM me for support, I will not respond anyway.

Share this post


Link to post
Share on other sites

iantates, if you place a copy of abspath.php in the system_backup directory and point your browser to it, what does it show?

 

Whant ever it points to, that is what you need to put in this line:

 

$backupto = "/home3/wendy/simplyfancydress-www/admin/system_backup";

        //Change to the absolute path to your /admin/system_backup directory

 

It could be something like:

/home3/wendy/simplyfancydress-www/catalog/admin/system_backup/

Or:

/home3/wendy/simplyfancydress-www/store/admin/system_backup/

Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

Found the solution to displaying and downloading the backup file after it's been created.

 

In the system_backup.php after the last ?> add this piece of code:

<?php

function directory($result) {

 

    $handle=opendir("./system_backup");

    while ($file = readdir($handle)) {

    if ($file == "." || $file == "..") { } else { print "<a href=system_backup/$file>$file</a><br>\n"; }

   

    }

    closedir($handle);

 

return $result;

}

?>

<b>Select the file you want to Download:</b>

<p>

<?php

echo directory($result);

?>

 

This will give you a list of all the files in your system_backup directory so when you click on one it should give you the "save as" dialog prompt.

 

Happy hunting,

 

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

Bob

 

The path is points to is /home3/wendy/simplyfancydress-www/admin/system_backup

 

Which I believe is the same as already in the sysbackup.php!

 

If my database is large would I get this problem?

 

I have tried to follow the update as suggested by kooyan but have got completely lost!

Share this post


Link to post
Share on other sites
Bob

 

The path is points to is /home3/wendy/simplyfancydress-www/admin/system_backup

 

Which I believe is the same as already in the sysbackup.php!

 

If my database is large would I get this problem?

 

I have tried to follow the update as suggested by kooyan but have got completely lost!

 

Check with your webhost and ask if they allow passthru to be used on there servers, the backup may show complete but not actully create the file.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

Bob G

 

I have checked with my server host and they state passthru will work on their servers!

 

I have tried kooyan suggestion re file which is shown earlier in the forum and that backsup the database files no problem.

 

Not sure what is stopping it from working but thanx anyway for your help!

Share this post


Link to post
Share on other sites
Bob G

 

I have checked with my server host and they state passthru will work on their servers!

 

I have tried kooyan suggestion re file which is shown earlier in the forum and that backsup the database files no problem.

 

Not sure what is stopping it from working but thanx anyway for your help!

 

Try this, look through all your admin directories and see if you find a file that looks something like this "bak_20040326.tar" (date will be different), if you find it, thats where the systembackup.php is putting it. You can then move the system_backup folder in the same directory.

 

Other than that, I'm out of ideas, sorry. :(

 

Bob G.


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

Thanks for the quick reply and suggestion.

 

I can't find the file so it would seem that for some reason it isn't creating a backup even thou the success message is displayed.

 

When I click on system backup the success message is displayed almost instantly yet if I backup using database backup it takes a little while(1-2mins).

 

My site contains a lot of images and therefore the data is large. I am right in thinking that this contrib will backup the database aswell as whatever is contained in the folder which path is set in sysbackup?

 

May be due to the size of data to be backed up this is what is stopping it from happening (Hope that makes sense!)

 

 

 

Try this, look through all your admin directories and see if you find a file that looks something like this "bak_20040326.tar" (date will be different), if you find it, thats where the systembackup.php is putting it. You can then move the system_backup folder in the same directory.

 

Other than that, I'm out of ideas, sorry.  :(

 

Bob G.

Share this post


Link to post
Share on other sites

First you do a backup of your sql-db with the standard backup tool of osc. May take a while. This is stored in the osc backup folder as one file. Or you use my script., for larger sql-files.

 

Than you use bobg7s script which backup than the whole OSC-Folder incl. the sql dump which you made before.

 

This should take also a while !

 

HTH

 

Stefan Fritsche

www.klosterbrauerei.com

Edited by kooyan

Share this post


Link to post
Share on other sites

Installed the latest versoin of this as of today.

I get the same problem about it going stright to saying its finished, but not actually creating the file.

I checked with the host, they claim they have no issue with using this mod and passthru,.

 

The paths set are as returned in the abspath.php when ran.

 

any one have ideals yet?

 

Tom


no bugs in my stuff,,, just random features ;)

Share this post


Link to post
Share on other sites

To be honest, I'm not sure why it works for most and not for a few.

 

Are you on a Windows server by chance?


Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Share this post


Link to post
Share on other sites

No, not on windows server,, on a shared hosting / Linux 2.4.29

Apache/1.3.33 (Unix)

mod_auth_passthrough/1.8

mod_log_bytes/1.2

mod_bwlimited/1.4

PHP/4.3.10

FrontPage/5.0.2.2635

mod_ssl/2.8.22

OpenSSL/0.9.7a

 

and as I said,, tech support states passthru is ok,

well,, that they have no problem with it.

 

 

hmm,,

anyone with any info, I would be greatful if you could share ;)

 

Regards

Tom


no bugs in my stuff,,, just random features ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×