Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHP incremental backup library

License

NotificationsYou must be signed in to change notification settings

iobotis/php-incremental-backup

Repository files navigation

PHP incremental backup is a php library designed to support setting incremental backups run by cron scripts.The library is a wrapper to different commands

Tools supported

These tools are used to perform incremental backups on the directories chosen.

Requirements:

  • php 5.4 or greater installed.
  • one of the above libraries to be installed in your system.

How to install

  1. Using composer

composer require iobotis/php-incremental-backup

  1. Download and runcomposer installFollow the examples in the examples folder

Examples:

  1. Simple Duplicity backup.
useBackup\Tools\FactoryasToolFactory;$settings =array('path_to_backup' =>$path_to_backup,'destination' =>array('type' =>'local','path' =>'/path/to/save'    ),//    'passphrase' => 'abcdef',//    'exclude' => array('folder'));$backup = ToolFactory::create('Duplicity',$settings);$backup->execute();
  1. Simple Duplicity backup with wrapper class.
useBackup\Tools\FactoryasToolFactory;useBackup\IncrementalBackup;useBackup\Tools\FactoryasToolFactory;$settings =array('path_to_backup' =>$path_to_backup,'destination' =>array('type' =>'local','path' =>'/path/to/save'    ),//    'passphrase' => 'abcdef',//    'exclude' => array('folder'));$backup = ToolFactory::create('Duplicity',$settings);$backupClass =newIncrementalBackup ($backup);$backups =$backupClass->getAllBackups();foreach ($backupsas$time) {echo'There is a backup at' .$time ."\n";}if($backupClass->isChanged() ) {// back me up.echo'Back up initiated' ."\n";$backupClass->createBackup();}else {echo'No need to backup.' ."\n";}
  1. Simple Duplicity backup restore last backup.
useBackup\Tools\FactoryasToolFactory;useBackup\IncrementalBackup;$settings =array('path_to_backup' =>$path_to_backup,'destination' =>array('type' =>'local','path' =>'/path/to/save'    ),//    'passphrase' => 'abcdef');$duplicity = ToolFactory::create('Duplicity',$settings);$backupClass =newIncrementalBackup ($duplicity);// Restore last backup to this directory.$backupClass->restoreTo(end($backups ),'/path/to/restore');
  1. Simple Tar backup.
useBackup\Tools\FactoryasToolFactory;useBackup\IncrementalBackup;$settings =array('path_to_backup' =>$path_to_backup,'destination' =>array('type' =>'local','path' =>$path_to_save    ),//'exclude' => array('exclude', 'exclude1'));$backup = ToolFactory::create('Tar',$settings);$backupClass =newIncrementalBackup ($backup);$backups =$backupClass->getAllBackups();foreach ($backupsas$time) {echo'There is a backup at' .$time ."\n";}if($backupClass->isChanged() ) {// back me up.echo'Back up initiated' ."\n";$backupClass->createBackup();}else {echo'No need to backup.' ."\n";}
  1. Tar restore last backup.
useBackup\Tools\FactoryasToolFactory;useBackup\IncrementalBackup;$settings =array('path_to_backup' =>$path_to_backup,'destination' =>array('type' =>'local','path' =>$path_to_save    ),);$backup = ToolFactory::create('Tar',$settings);$backupClass =newIncrementalBackup ($backup );$backups =$backupClass->getAllBackups();// Restore last backup to this directory.$backupClass->restoreTo(end($backups ),'/path/to/restore' );

Advanced usage

1)Duplicity without Factory

useBackup\Binary;useBackup\FileSystem\Source;useBackup\Destination\FactoryasDesFactory;useBackup\Tools\Duplicity;useBackup\FileSystem\Folder;$binary =newBinary('/usr/bin/duplicity');$source =newSource('/var/www/example_com');$destination = DesFactory::create('/var/backups/example_com');$duplicity =newDuplicity($source,$destination,$binary);$duplicity->setArchiveDir('/var/www/cache');$duplicity->setExludedSubDirectories(array('cache','logs','tmp'));// check if duplicity is installed.$duplicity->isInstalled();// get duplicity version.$duplicity->getVersion();// verify backup location.$duplicity->verify();// backup if needed.$duplicity->execute();// retrieve existing backups.$backups =$duplicity->getAllBackups();// restore 1st backup.$folder =newFolder('/var/www/example_com');$duplicity->restore($backups[0],$folder);

How to run unit tests

From the root folder run:php {location of phpunit phar}/phpunit.phar

orInstall composer dependencies and run the scripts defined in composer.json.

About

PHP incremental backup library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp