Skip to main content

Snapshot you btrfs subvolumes and apply a retention policy

Project description

Take snapshots of your btrfs subvolumes and apply a retention policy in order to keep your snapshot directory somewhat clean and small.

The retention policy, defined bellow, is hardcoded for now but it should be enought for the average use case. I may adjust it, or provide a way to change it at runtime if needed.

  • Hourly snapshots are kept for 24 hours

  • Daily snapshots are kept for 4 weeks

  • Weekly snapshots are kept for 12 weeks

  • Monthly snapshots are kept for a year

  • yearly snapshots are kept for 10 years

Every subvolume that should be snapshoted must be given as argument to the script. For example if you want to snapshot every home directory created as subvolumes and your /etc and /srv directory you would do

btrfs-simple-snapshots /home/* /etc /srv

Once done, you will find a new subvolume named .snapshots inside the snapshoted subvolume with a name formated as %Y-%m-%d-%H%M%S

Installation

Install from pip using pip install btrfs-simple-snapshots. Then you can run it as root or with a user able to manage btrfs subvolumes. It is probably a good thing to run it automatically with a cron job. Depending on you need you may run it once per day (at 2 a.m.) to snapshot every home folder (created as subvolumes) with this kind of job definition.

0 2 * * * python -m btrfs_simple_snapshots /home/*

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

btrfs-simple-snapshots-0.1.0.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

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

btrfs_simple_snapshots-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file btrfs-simple-snapshots-0.1.0.tar.gz.

File metadata

File hashes

Hashes for btrfs-simple-snapshots-0.1.0.tar.gz
Algorithm Hash digest
SHA256 299133c93ae8a2b4bd581d2241140fb8fe5f65d7fea80ea5d1f030f588360716
MD5 a44b1275438cbc4aa353d189754e8c87
BLAKE2b-256 154083368c4b9e142b0ec1d16ff1a211e275fb41c7742e132642ac105993a31f

See more details on using hashes here.

File details

Details for the file btrfs_simple_snapshots-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for btrfs_simple_snapshots-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7b8d60434185a92251cc9c75b69cf6bc01a53a130a1f7fe3e041817358ac9ba
MD5 9ea52b1d6f7e7e1a9498a040caf1e888
BLAKE2b-256 2bf4c2ec4a4a9dfa809e9c1c5935b6f984a390247410adf88d8360eece612025

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