Skip to main content

Yet another rsync incremental backup utility

Project description

Yet another rsync based incremental backup utility.

Purpose

An utility to maintain incremental backups in differnet directories.

The backups in each directory will contain entire image, but the incremental nature comes from the fact that unchanged files will be hard linked sharing the same space across backups.

Setup and Usage

Installing

Run the following -

sudo pip3 install yaribak

You can leave out the sudo in most distributions, or if you don't want to backup with super-user privileges.

Usage

yaribak --help

yaribak \
  --source /path/to/source \
  --backup-path /path/to/backups

# Optional args (run with --help to view description) -
# --dryrun
# --verbose
# --only-if-changed
# --max-to-keep=3
# --exclude source_subdir1 --exclude source_subdir2 ...

Note: Care must be taken to use different backup directories for different source directories.

Example Usage

Maintain backups of the home directory -

# Create the backup directory.
mkdir -p /path/to/homdir_backups

# Call this every time you want to backup, or put it in cron.
# Past backups will be kept.
yaribak \
  --source ~ \
  --backup-path /path/to/homedir_backups \
  --verbose \
  --exclude .cache

The following structure will be generated in the backup directory (for this example, after 3 calls) -

$ ls path/to/homedir_backups
_backup_20220306_232441
_backup_20220312_080749
_backup_20220314_110741

Each directory will have a full copy of the source.

Yaribak features

Conserving Space

The primary reason to use this over a simple cp -r is that it saves space.

Any file that remains unchanged will be hard linked, effectively resulting in very little space consumption for multiple invocation if the source remains largely unchanged.

$ # Size of source directory.
$ du -sh ~
6.5G /home/user1

$ # Say following backups were created by multiple invocations -
$ ls path/to/homedir_backups
_backup_20220314_110741
_backup_20220314_110815
_backup_20220314_110903

$ # Assuming multiple backups were created with no change in source,
$ # total size of backup will not increase (by much).
$ du -h /path/to/homedir_backups
6.5G /path/to/homedir_backups

Fault Tolerance

If a backup is stopped abruptly in the middle, yaribak will recover next time you run it.

Testing

From the package root, run -

./runtests.sh

Alternatives

Comparison with Timeshift

Timeshift is an excellent utility to do one thing: backing up system.

It however cannot be used to backup any other directory, or to back up in user-selected destination.

This is an alternative to allow more control, but without conveniences like a GUI and out-of-the-box automated backups.

FAQ

How do I set up periodic backups?

You will need to add the backup command to cron. There are many excellent tutorials, for example this one.

Does it create hard links to original files?

No, even if they are on the same filesystem, backups will never be hard linked to source by design. Creating hard link to original files will result in the backups being modified if the original file is modified - that's something we do not want.

Can I use the same destination for different sources?

Using the same destination for different sources will result in the algorithm not evaluating unchanged files correctly across invocations. So it is strongly discouraged to use the same directory for different sources. Instead, assign different destination directories for different sources.

How do I restore?

You will need to manually copy all files from any of the backups to the source directory.

This can be done either by cp -ar -

# Save the existing files.
mv /path/to/source /path/to/source_old

# Restore.
cp -ar /path/to/backups/ysnap_20220314_110903/payload /path/to/source

Or using rsync -

# Warning: Existing files will be irrevokably modified or deleted.
rsync -aAXHv --delete \
  /path/to/backups/ysnap_20220314_110903/payload \
  /path/to/source

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaribak-0.0.4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaribak-0.0.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file yaribak-0.0.4.tar.gz.

File metadata

  • Download URL: yaribak-0.0.4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for yaribak-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7a390a87a6747824ae8947364a9fcf18ae8d34d54c1665596fad8a3d6a4a0335
MD5 4f3e96b2c4eaeecd69d5414c25c394db
BLAKE2b-256 1dc4567e2cac5a583d1e98b1a7c643bf51c92ffef23514051863ac7ef151b539

See more details on using hashes here.

File details

Details for the file yaribak-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: yaribak-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for yaribak-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14cf2d525eb30c33573f3a890005c2277524405d6025464ec78bb465fefbfe7c
MD5 f0fed03c67382b7a772fdd95acec93f9
BLAKE2b-256 a736f56429a1bf44f2ae6cd5c144a14235825783c53f37e44fcb91c69fdea6f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page