Chak10 / Backup-Dirs

Compressing a folder in different formats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backup folders

Compressing a folder and its subfolders in different formats (.zip | .tar.gz | .tar.bz2).

function __construct($dirs, $destination = "backup_site.zip", $comp = 'gz', $index = 9, $memory = false) {}
  1. $dirs (String or Array) => The folder/s you need to backup. (Even more folders)
  2. $destination => Destination folder.
  3. $comp => Compression type. (Usually no need to modify it)
    • Zlib => gz
    • Bzip2 => bz2
    • Zlib => deflate
  4. $index => Compression index. (Usually no need to modify it) Min 0 | Max 9
  5. $memory => ONLY in case of memory problems, set it to true (It's not miraculous).

USE

$from_dir = "../admin";
$to_filepath = "../backup_files.zip"; // or "../backup_files.tar"
$bk = new backup_dirs($from_dir, $to_filepath);
if ($bk->res !== true)
    echo $bk->err;
else
    echo "Done";
$from_dir = array(
    "../admin",
    "../cache",
    "../config"
); //With this method, the .tar extension is not supported.
$to_filepath = "../backup_files.zip";
$bk = new backup_dirs($from_dir, $to_filepath);
if ($bk->res !== true)
    echo $bk->err;
else
    echo "Done";

Required PHP Version > 5.3.0 | PHAR Extension or Zip Extension.

About

Compressing a folder in different formats

License:GNU Lesser General Public License v3.0


Languages

Language:PHP 100.0%