Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Backup your files


bobg7

Recommended Posts

Posted

I have seen a lot of questions on how to backup your OSC Files and the standard answer is to use the Database Backup in the Admin Panel and to FTP your site to your PC. I know when I do the FTP of my entire site it will timeout and I have to restart and it seems to take forever.

 

So here are a few scripts I found to make life a little easier.

 

The first one is to find the absoulute path to your website if you don't already know it.

 

<?php

echo getcwd();

?>

 

Copy it into Notepad and save it as abspath.php, upload it to the root directory of your website and point your browser to it. This will display a new page with your absoulute path, write this down.

 

The next script will execute a backup of your website,

 

<?php

        $backupdate = date("Ymd");

        //Backup date variable. Replace "Ymd" with

        //"Ymd_H-i" to include the time.

 

        $backupdir = "/the/absolute/path/to/the/folder/";

        //Where are the files located?

       

        $files = "*";

        //What file to backup? Use a * to backup all the files

        //inside the folder entered above.

       

        $backupto = "/the/absolute/path/to/the/folder/sitebackup/";

        //Where to store the tarball?

 

        $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,$bz2arg,$files;

$backupsuscmd = "cd $backupdir;

    tar $tararg {$fileprefix}_{$backupdate}.tar $files;

    bunzip2 $bz2arg {$fileprefix}_{$backupdate}.tar;

    mv {$fileprefix}_{$backupdate}.tar $backupto";

  passthru ("$backupsuscmd");

  }

?>

 

Now copy and paste this into Notepad and change the absoulute path to the one you got earlier. and save it as sitebackup.php.

 

FTP this file up to the root directory of your website and create a new folder called sitebackup and CHMOD to 777 or 755.

 

Point your browser to the script, depending on how big your website is, it will run for several minutes ending on a blank page.

 

Now all you need to do is open the sitebackup folder and FTP it down to your PC.

 

I give credit for the scripts to Adam LeVasseur who posted the scripts on This Webpage,

 

Also, I have no clue on how to create a contribution for this or I would have.

 

Hope everyone finds this to be usefull.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...