iobotis/php-incremental-backup
Composer 安装命令:
composer require iobotis/php-incremental-backup
包简介
PHP library to support file incremental backups
README 文档
README
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
- Using composer
composer require iobotis/php-incremental-backup
- Download and run
composer installFollow the examples in the examples folder
Examples:
- 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();
- 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"; }
- 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');
- 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"; }
- 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
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
From the root folder run: php {location of phpunit phar}/phpunit.phar
or Install composer dependencies and run the scripts defined in composer.json.
iobotis/php-incremental-backup 适用场景与选型建议
iobotis/php-incremental-backup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 266 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 03 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「backup」 「tar」 「incremental」 「duplicity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iobotis/php-incremental-backup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iobotis/php-incremental-backup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iobotis/php-incremental-backup 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A library for dynamically streaming dynamic tar files without the need to have the complete file stored on the server.
A library for dynamically streaming dynamic tar files without the need to have the complete file stored on the server.
Lightweight incremental streaming JSON parser
A SDK for working with B2 cloud storage.
Automatic unique ID for Pages, Files and nested Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
A simple YouTube API wrapper library.
统计信息
- 总下载量: 266
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-07