Skip to main content

backups with `rsync` and `btrfs` snapshots

Project description

what

performs incremental backups with rsync onto a btrfs filesystem. finished backups are retained as read-only snapshots.

usage

install

pip install snapshotbackup
pip install snapshotbackup[ci]          # install ci related dependencies
pip install snapshotbackup[dev]         # install dev dependencies
pip install snapshotbackup[journald]    # enable logging to journald with `--silent`

example config.ini

[DEFAULT]
; retain_all = '1 day'
; retain_daily = '1 month'
; decay = '1 year'

[data1]
source = /path/to/data1
backups = /backups/data1

[data2]
source = /path/to/data2
backups = /backups/data2
ignore = /.cache
retain_all = '1 week'
; '1', 'true' or 'True' for `True`, everything else is `False`
autodecay = 1
autoprune = true

actions

the setup-step can be skipped if configured backup directory already exists.

snapshotbackup setup data1
snapshotbackup backup data1
snapshotbackup list data1
snapshotbackup prune data1
snapshotbackup decay data1

retention policy

prune will preserve:

  • all backups not older than retain_all
  • daily backups not older than retain_daily
  • weekly backups forever (see decay)
  • the latest backup is always preserved

decay removes all backups older than configured decay.

automatization

when using advanced installation methods and cron make sure PATH is properly setup, f.e.

PATH=/usr/local/bin:/bin:/usr/bin:/home/foo/.local/bin
01 * * * * DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus snapshotbackup backup home -s

to allow non-interactive deletions configure sudo to allow your user "foo" to use some btrfs commands without password.

foo ALL=(ALL) NOPASSWD: /usr/bin/btrfs subvolume list *
foo ALL=(ALL) NOPASSWD: /usr/bin/btrfs subvolume delete *

dev env

virtualenv .env -p python3
. .env/bin/activate
pip install -e .[dev]  # or pip install -e .[dev,journald]

on zsh you may need to quote:

pip install -e ".[dev]"

demo

if you don't have a btrfs filesystem at hand checkout the demo folder. it creates a btrfs image file and mounts it as loopback device.

DISCLAIMER: i'm not sure if btrfs loopback files are safe in every environment. use at your own risk.

make -f makefile.demo setup
make -f makefile.demo backup
make -f makefile.demo list
make -f makefile.demo prune
make -f makefile.demo decay
make -f makefile.demo clean

please read makefile.demo and demo/config.ini to understand what's happening.

build

./setup.py bdist_wheel

that's all

not enough documentation? well, erm.., intended audience are developers. that's what you get for hobby projects ;-)

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

snapshotbackup-0.0.18.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

snapshotbackup-0.0.18-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file snapshotbackup-0.0.18.tar.gz.

File metadata

  • Download URL: snapshotbackup-0.0.18.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for snapshotbackup-0.0.18.tar.gz
Algorithm Hash digest
SHA256 1b3ee9b7b4039896aa511cd2c1690951c281d85eb065e0dd26e079450063c42e
MD5 753ffc98fb51453779e9eb6acbdb2073
BLAKE2b-256 0026e9b68884bceacec848fd7a7f210f619593f3ad34b211d1e714e6babdc935

See more details on using hashes here.

File details

Details for the file snapshotbackup-0.0.18-py3-none-any.whl.

File metadata

File hashes

Hashes for snapshotbackup-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 cc4362448aa09ff1f7853981539c26695511c92139b9a29aaded2f6aa7a635ab
MD5 3445d961e395fd64737b6fb56711b326
BLAKE2b-256 5fdeac508ae276f0fe9dcc6d681c602c8cd1e1b7aad20dabab58bf82e9da9db6

See more details on using hashes here.

Supported by

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