Documentation of J_back_files php class

This is a class to export or backup your server data. It creates a single downloadable file of multiple files by scanning the specified directory recursively. A copy of the same class can be used to extract the compressed file created by it. I tested it with a directory of 4.19MB with 300 files in 23 folders, and got a compressed file of 1.01MB

Usage and Example of J_back_files

It can be used to move huge data when switching hosting providers, or create backup of client files by hosting providers by setting a cron.

Class is controlled by 3 external variables and 2 function calls (1 for backing up and second for extracting).

Once the class is initialized, you need to set the following variables:

To make the backup, make a call to the function: make_backup() It returns the size of the compressed file in MB

To extract the compressed file call the function: load_backup() which returns 1 on success. Once you have called this function, you can scan the new target location and get the array like this: print_r($class->result) It will list all files and folders that are created

Example: (These are the contents of the example.php file supplied with the class )

require_once 'backup.class';

$z= new BackUP;

$z->source_dir= 'test/original/';

$z->target_dir= 'test/new/';

$z->file_created= 'test/backup.szip';

echo '<p> Creating a backup of: '. $z->source_dir. '</p>';

echo '<p> Extracting the backup to: '. $z->target_dir. '</p>';

echo "<p> <a href='". $z->file_created. "' target='_blank'> Backup File </a> is: ". $z->make_backup(). " MB </p>";

 

// to extract the backed file

$z->load_backup();

echo '<h4> Scanning target location: </h4> <pre>'; print_r($z->result); echo '</pre>';

Sites that use this class: