Download the PHP package muckiware/restic without Composer

On this page you can find all versions of the php package muckiware/restic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package restic

muckiware/restic

PHP client for restic backup tool. This library provides a simple way to create and manage backups with restic. It uses repositories as storage for backups.

[![Latest Stable Version](http://poser.pugx.org/muckiware/restic/v)](https://packagist.org/packages/muckiware/restic) [![Total Downloads](http://poser.pugx.org/muckiware/restic/downloads)](https://packagist.org/packages/muckiware/restic) [![PHP Version Require](http://poser.pugx.org/muckiware/restic/require/php)](https://packagist.org/packages/muckiware/restic) [![Dependents](http://poser.pugx.org/muckiware/restic/dependents)](https://packagist.org/packages/muckiware/restic) [![License](https://img.shields.io/github/license/shopware/shopware.svg)](https://github.com/shopware/shopware/blob/trunk/LICENSE)

Requirements

Usage

How to use the library. This php client interacts with the restic binary to create, manage and restore backups in and of a repository. The first step is always to create a backup repository as storage for the backup data. After that, you can create backups in this repository and check the backup data. And at least if its necessary, you can restore the backup data.

Location of backup repository

The backup repository can be located on the local file system, or on an external S3 storage. Currently this library supports AWS / AmazonS3 as external storage for the backup repository. More details about the Amazon Bucket configuration in the restic documentation https://restic.readthedocs.io/en/latest/080_examples.html#setting-up-restic-with-amazon-s3

Overview commands

This gives you an overview of the possible methods of the framework. The default value for repositoryLocationTypes is local.

MuckiRestic\Library\Backup\Backup::[method];

Method Parameter variable name [type of variable] Description
createRepository() $overwrite[bool],
$repositoryLocationTypes[RepositoryLocationTypes] (optional)
Creates a new backup repository
createBackup() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Creates a backup with and creates a new snapshot in the backup repository
checkBackup() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Checks a repository and reads all data for testing

MuckiRestic\Library\Backup\Manage::[method];

Method Parameter variable name [type of variable] Description
getSnapshots() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Get a list of all snapshots in specific repository
removeSnapshots() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Removes snapshots by snapshot ids
removeSnapshotById() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Removes a snapshot by specific snapshot id
executePrune() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Performance a clean up of old items after a remove command. Its saved hd space.
getRepositoryStats() $repositoryLocationTypes[RepositoryLocationTypes] (optional) Get a list of statistic values of a specific repository

MuckiRestic\Library\Restore::[method];

Method Parameter variable name [type of variable] Description
createRestore() $overwrite[bool],
$repositoryLocationTypes[RepositoryLocationTypes] (optional)
Creates a restore of a specific snapshot

Create a new backup repository

You will need first the backup object of the library, for to use the createRepository method. Import this class with use MuckiRestic\Library\Backup;. The Backup-class has a static create-method for to get the Backup object, like this $backupClient = Backup::create();. With this create, you have access to all the Backup methods. The $backupClient->createRepository() method initialize a new repository and need the required parameters password and the repositoryPath. The repositoryPath is where the backup data will be stored and the password is used to encrypt the backup data. It's required for all operations on the repository. It has to be set by the two setting methods $backupClient->setRepositoryPassword('1234') and $backupClient->setRepositoryPath('./path_to_repository')
Optionally you can set the path for the restic binary, with $backupClient->setBinaryPath('./bin/restic_0.17.3_linux_386'). This is necessary if the restic binary is not installed in the local system.

The method createRepository() returns the object ResultEntity.

The method getOutput of the object ResultEntity returns the output of the restic command. If an error occurs, an exception will be thrown.

Example for local repository

Example for Amazon S3 storage

Create a backup

Next step, create a backup into the repository by using the method $backupClient->createBackup(). Also, this method will returns the object ResultEntity. The backup path is required for the backup operation. It has to be set by the method $backupClient->setBackupPath('./path_to_backup_folder').
Every backup process creates a new snapshot of the backup data in the repository. These snapshots are represented by an individually hash string.

Example for local repository

Example for Amazon S3 storage

Check the backup

After the backup process, it makes sense to check the backup data. The method $backupClient->checkBackup() will return the object ResultEntity. The method getOutput of the object ResultEntity returns the output of the restic command simple as string. If an error occurs, an exception will be thrown.

Example for local repository

Example for Amazon S3 storage

Manage backups

The library provides methods for to manage backups. Import this class with use MuckiRestic\Library\Manage;.

Get list of snapshots

You can get list of all snapshots of a repository with the method $manageClient->getSnapshots(). The method getSnapshots returns the object ResultEntity. The method getOutput of the object ResultEntity returns the output of the restic command simple as string. If an error occurs, an exception will be thrown.

Example for local repository

Example for Amazon S3 storage

Remove snapshot by id

You can remove a snapshot of a repository by id with the method $manageClient->getSnapshots(). The method getSnapshots returns the object ResultEntity. The method getOutput of the object ResultEntity returns the output of the restic command simple as string. If an error occurs, an exception will be thrown.

Example

Example for Amazon S3 storage

Remove old snapshots

You can remove old snapshots of a repository with the method $manageClient->removeSnapshots(). This is kind a like a cleanup run for the repository. The method removeSnapshots returns as always the object ResultEntity. The method getOutput of the object ResultEntity returns the output of the restic command simple as string. If an error occurs, an exception will be thrown.
This cleanup run needs to be setup with the keep-parameters, which defined the number of daily, weekly, monthly and yearly snapshots to keep. The method setKeepDaily(int $keepDaily), setKeepWeekly(int $keepWeekly), setKeepMonthly(int $keepMonthly) and setKeepYearly(int $keepYearly) are used to set the keep-parameters.

default keep-parameters

Parameter value
$keepDaily 7
$keepWeekly 5
$keepMonthly 12
$keepYearly 75

More details about the keep-parameters you can find in the restic documentation https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy

Example for local repository

Example for Amazon S3 storage

Restore a backup

You can restore a backup from a repository with the method $restoreClient->restoreBackup(). The method restoreBackup returns also the object ResultEntity. The method getOutput of the object ResultEntity returns the output of the restic command simple as string. If an error occurs, an exception will be thrown.
As default the method restoreBackup will restore the latest snapshot. Optionally you can set the snapshot hash with the method setRestoreItem(string $snapshotHash). The snapshot hash you can get from the method getSnapshots.

Example for local repository

Example for Amazon S3 storage

Use as cli app

Checkout the App folder for to run as cli command

Get version of restic binary

Init a new backup repository

Run phpstan tests

License

MIT License (MIT). Please see LICENSE File for more information.

Notice

If you run muckiware/restic on a ddev/Docker environment, you could get a read/error of the backup files. In this case, check the mutagen status, and enable the mutagen sync. This library is only checked on a Linux and MacOS environment. All components are also available for Windows, but no warranty that is also working on a Windows environment.


All versions of restic with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
netresearch/jsonmapper Version ^5.0
symfony/process Version ~v5.0|~v6.0|~v7.0
symfony/console Version ~v5.0|~v6.0|~v7.0
doctrine/collections Version ^2.3
symfony/dotenv Version ^7.0 || ^6.0
aws/aws-sdk-php Version ^3.369
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package muckiware/restic contains the following files

Loading the files please wait ...