Thought I would pass this backup script for you all to use so you can save yourself a lot of headaches.
First, create a new directory called
system_backup with permissions of 777
Next, edit the script to reflect the absolute paths to the root of your site and the absolute path to the system_backup directory, a script is included to get the absolute path if you need it.
Replace the ????????'s with the absolute path, save it.
The script I call
backup.php
Code:
<?php
/*
$Id: sysbackup.php,v1.0a 2005/01/02 01:53:52 hpdl Exp $
Released under the GNU General Public License
*/
$backupdate = date("Ymd_H-i-s");
//Backup date variable. Replace "Ymd" with
//"Ymd_H-i-s" to include the time.
$backupdir = "/home/www/?????????.com";
//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 = "/home/www/???????????/system_backup";
//Change to the absolute path to your 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");
}
?>
<?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>Your System Backup is now complete! FTP the backup file to your PC for safe keeping and delete it from the server to save space.</b>
<p>
FTP the script to the root of your website, to execute it just point your browser to backup.php (
http://www.?????.com/backup.php). Depending on how large your site is it may run just a few seconds or a few minutes.
Remember to FTP the .tar file to your PC and delete it from your webspace to save space.
Not sure of the absolute path? Here is a short script the will tell you:
abspath.phpCode:
<?php
/*
$Id: abspath.php,BETA 2005/01/02 01:56:52 hpdl Exp $
Released under the GNU General Public License
*/
echo getcwd();
?>
Copy and paste it into notepad, save it as abspath.php and FTP to to the root of your website, point your browser to it and it will display.
This script should work for everyone and I use it on a weekly basis on two websites I host here.
Hope this helps,
Bob G.
_________________
Bob G.
Grout Recoloring Systems:
http://coloryourgrout.com
Save Your Data - Do Backups
http://forum.100webspace.com/viewtopic. ... highlight=