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)142598[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 1w 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 59% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity24

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

3162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bbc83d56229e03b413fef60e1fa64d3f1feacccac09247bf514e2480329b8444?d=identicon)[iobotis](/maintainers/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

[pear/archive_tar

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

7661.0M73](/packages/pear-archive-tar)[zanysoft/laravel-zip

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

3142.8M15](/packages/zanysoft-laravel-zip)[wapmorgan/unified-archive

UnifiedArchive - an archive manager with unified interface of working with all popular archive formats (zip/7z/rar/gz/bz2/xz/cab/tar/tar.gz/tar.bz2/tar.x/tar.Z/...) for PHP with ability for listing, reading, extracting and creation + built-in console archive manager.

2791.6M7](/packages/wapmorgan-unified-archive)[splitbrain/php-archive

Pure-PHP implementation to read and write TAR and ZIP archives

1061.4M20](/packages/splitbrain-php-archive)[gliterd/backblaze-b2

PHP SDK for working with backblaze B2 cloud storage.

84263.3k8](/packages/gliterd-backblaze-b2)[barracudanetworks/archivestream-php

A library for dynamically streaming dynamic tar or zip files without the need to have the complete file stored on the server.

77192.2k1](/packages/barracudanetworks-archivestream-php)

PHPackages © 2026

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