PHPackages                             iobotis/php-incremental-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. iobotis/php-incremental-backup

ActiveLibrary[File &amp; Storage](/categories/file-storage)

iobotis/php-incremental-backup
==============================

PHP library to support file incremental backups

v1.0(8y ago)142628[7 issues](https://github.com/iobotis/php-incremental-backup/issues)[1 PRs](https://github.com/iobotis/php-incremental-backup/pulls)MITPHPPHP &gt;=5.4.0

Since Sep 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iobotis/php-incremental-backup)[ Packagist](https://packagist.org/packages/iobotis/php-incremental-backup)[ Docs](https://github.com/iobotis/php-incremental-backup)[ RSS](/packages/iobotis-php-incremental-backup/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

php-incremental-backup
======================

[](#php-incremental-backup)

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
---------------

[](#tools-supported)

- [Duplicity](http://duplicity.nongnu.org/)
- [Tar](https://www.howtoforge.com/tutorial/linux-tar-command/)
- [Borg backup](https://borgbackup.readthedocs.io/en/stable/)

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

Requirements:
-------------

[](#requirements)

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

How to install
--------------

[](#how-to-install)

1. Using composer

`composer require iobotis/php-incremental-backup`

2. Download and run `composer install`Follow the examples in the examples folder

Examples:
---------

[](#examples)

1. Simple Duplicity backup.

```
use Backup\Tools\Factory as ToolFactory;

$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();
```

2. Simple Duplicity backup with wrapper class.

```
use Backup\Tools\Factory as ToolFactory;
use Backup\IncrementalBackup;

use Backup\Tools\Factory as ToolFactory;

$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 = new IncrementalBackup ($backup);

$backups = $backupClass->getAllBackups();
foreach ($backups as $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";
}
```

3. Simple Duplicity backup restore last backup.

```
use Backup\Tools\Factory as ToolFactory;
use Backup\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 = new IncrementalBackup ($duplicity);

// Restore last backup to this directory.
$backupClass->restoreTo(end( $backups ), '/path/to/restore');
```

4. Simple Tar backup.

```
use Backup\Tools\Factory as ToolFactory;
use Backup\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 = new IncrementalBackup ($backup);

$backups = $backupClass->getAllBackups();
foreach ($backups as $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";
}
```

5. Tar restore last backup.

```
use Backup\Tools\Factory as ToolFactory;
use Backup\IncrementalBackup;

$settings = array(
    'path_to_backup' => $path_to_backup,
    'destination' => array(
        'type' => 'local',
        'path' => $path_to_save
    ),
);

$backup = ToolFactory::create('Tar', $settings);
$backupClass = new IncrementalBackup ( $backup );

$backups = $backupClass->getAllBackups();

// Restore last backup to this directory.
$backupClass->restoreTo( end( $backups ), '/path/to/restore' );
```

Advanced usage
--------------

[](#advanced-usage)

1)Duplicity without Factory

```
use Backup\Binary;
use Backup\FileSystem\Source;
use Backup\Destination\Factory as DesFactory;
use Backup\Tools\Duplicity;
use Backup\FileSystem\Folder;

$binary = new Binary('/usr/bin/duplicity');
$source = new Source('/var/www/example_com');
$destination = DesFactory::create('/var/backups/example_com');

$duplicity = new Duplicity($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 = new Folder('/var/www/example_com');
$duplicity->restore($backups[0], $folder);
```

How to run unit tests
---------------------

[](#how-to-run-unit-tests)

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

or Install composer dependencies and run the scripts defined in composer.json.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3208d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3168906?v=4)[Ioannis Botis](/maintainers/iobotis)[@iobotis](https://github.com/iobotis)

---

Top Contributors

[![iobotis](https://avatars.githubusercontent.com/u/3168906?v=4)](https://github.com/iobotis "iobotis (116 commits)")

---

Tags

backupbackup-scriptbackup-utilityduplicity-backupincremental-backupsbackuptarincrementalduplicity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iobotis-php-incremental-backup/health.svg)

```
[![Health](https://phpackages.com/badges/iobotis-php-incremental-backup/health.svg)](https://phpackages.com/packages/iobotis-php-incremental-backup)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[spatie/laravel-backup

A Laravel package to backup your application

6.0k24.4M244](/packages/spatie-laravel-backup)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[pear/archive_tar

Tar file management class with compression support (gzip, bzip2, lzma2)

7665.3M92](/packages/pear-archive-tar)[zanysoft/laravel-zip

laravel-zip is the world's leading zip utility for file compression and backup.

3203.0M15](/packages/zanysoft-laravel-zip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
