Tuesday, February 23, 2010

How to backup a website through php

I have several websites and always get into troubles transferring all of the files because it takes so long even if the size is so small... but they are to many... ;) so I thought that could be useful to compress them in only one file and transfer it as one.
How to make that ? quick dirty and easy through the usage of a piece of software from GiveMeEnergy Projects, by ThoR<AE> :

1. you need the attached library class.backup.php
2. you need to make a script like the following:

include("class.backup.php");
$bk= $_GET['dir'];
$bckdir="./backupFiles";
if($bk === NULL){
   echo "Missing dirname <br>";
   echo "usage: http://url/backup.php?dir=./DIRNAME_WITHOUT_/";
}
else{
                $filename       = date("Y_m_d__H_i");
                ###     Start Class                     ###
                $mkBackup       = new BackUp;
                ###     Folder to Backup                ###
                $mkBackup->WhatBackup($bk);
                ###     Where to put the gzipped file   ###
                $mkBackup->WhereBackup($bckdir);
                ###     Save as...                      ###
                $mkBackup->FileName($filename);
                ###     If You want to echo the info    ###
//              $mkBackup->Debug();
                ###     Run Backup                      ###
                echo "backup doing <br>";
                $mkBackup->Backup();
                echo "backup done <br>";
                ###     Set Filename .sql               ###
                echo "backup doing db<br>";
                $mkBackup->DBFileName($filename.".sql");
                $mkBackup->DBMakeBackup("SERVER_IP","","USER","PASS","DBNAME");
                echo "backup done db";
                echo "you can find the files here:<br>";
                echo "<a href=\"./$bckdir/$filename.tar.gz\">$filename.tar.gz</a>";
                echo "<br><a href=\"./$filename.sql\">$filename.sql</a>";}
echo "<br> this is provided by <a href=\"http://www.lxphotostudio.info\">Lxphotostudio";
?>

thats it
come to visit my web site at www.lxphotostudio.info or lxphotostudio.mine.nu

alex

No comments:

Post a Comment