Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to easily create a container backup (#161)
The `disk_objectstore.backup_utils` module is added that contains various utilities that make it easy to create a backup of a container. It was designed with the following criteria in mind: * Backup should use rsync to make incremental backup as efficient as possible. * The mechanism should support keeping a certain number of backups in the target location, removing the oldest copies if the number exceeds the target number. * The mechanism should support backing up to a target that is reachable over an SSH connection. * The mechanism should be easily reusable by other storage solutions that use the disk objectstore as part of the storage, e.g., `aiida-core`. * The mechanism should work safely while the storage is being used. The `BackupManager` class implements all functionality that relates to copying files (over SSH or locally) using rsync and keeping the target number of backup copies. It takes a callable that should contain the actual backup logic to create a backup of a containers contents. The callable should take an instance of the `BackupManager` as a first argument as it should use its `call_rsync` method to copy any files to the target directory. This design makes for a slightly awkward cyclic dependency where the manager calls a callable which takes the manager as an argument, but this is done to make the actual backup logic configurable by other packages. The actual container backup logic is implemented in `backup_container` which is the callable passed to `BackupManager.backup_auto_folders`. This function carefully copies the content of a container's folder to the target directory in a specific order which guarantees that the backup is coherent even while the container is actively being used.
- Loading branch information