btrfs based backup tool with daily/weekly/monthly/yearly schedules
- Simple bash script to create btrfs snapshots
- Snapshot groups for daily/weekly/monthly/yearly tasks
- Set custom retention policies for each backup group
- Time based locking to avoid unwanted snapshots (execute script multiple times in a row)
bsnapshot has one magic command called backup
- it executed the daily/weekly/monthly/yearly schedules and finally applies the backup retention policies to remove outdated snapshot.
Usage: bsnapshot [options...] <command>
btrfs based backup tool with daily/weekly/monthly/yearly schedules
Options:
-h,--help Displays this help
-v,--version Displays version
-c <filename> Use specific configuration file
Commands:
backup create snapshot(s) and apply retention policy
list List all available snapshots
Example
# ./bsnapshot backup
> daily snapshots enabled
no previous snapshot found
Create a readonly snapshot of '/mnt/backup' in '/mnt/data/.snapshots/daily/daily-20201020T190904'
snapshot created
> weekly snapshots enabled
no previous snapshot found
Create a readonly snapshot of '/mnt/backup' in '/mnt/data/.snapshots/weekly/weekly-20201020T190904'
snapshot created
> monthly snapshots enabled
no previous snapshot found
Create a readonly snapshot of '/mnt/backup' in '/mnt/data/.snapshots/monthly/monthly-20201020T190905'
snapshot created
> yearly snapshots enabled
no previous snapshot found
Create a readonly snapshot of '/mnt/backup' in '/mnt/data/.snapshots/yearly/yearly-20201020T190905'
snapshot created
To get an overview of all snapshots, just run the list
command:
Example
# ./bsnapshot list
/mnt/data/.snapshots
├── daily
│ └── daily-20201020T190904
├── monthly
│ └── monthly-20201020T190905
├── weekly
│ └── weekly-20201020T190904
└── yearly
└── yearly-20201020T190905
apt-get install bsnapshot
- Copy
bsnapshot
to/usr/sbin/bsnapshot
- Create the configuration file
/etc/bsnapshot.conf
You have to set a source directory (a btrfs subvolume + valid mountpoint) from which the snapshot should be created as well as a directory within the same btrfs filesystem which contains the snapshots. That's it!
File: /etc/bsnapshot.conf
...
# btrfs source volume
SOURCE_DIR="/mnt/data"
# snapshot storage directory within btrfs source volume
SNAPSHOT_DIR="/mnt/data/.snapshots"
The build-in data retention policy is executed after each backup. You can define how log a snapshot (subvolume) should exist before it's automatically removed by bsnapshot.
By setting a policy to zero (or left empty) the backup group will be disabled - no snapshot is created for the schedule nor the retention policy is applied
Configuration
File: /etc/bsnapshot.conf
...
# keep 14 daily snapshots
RETENTION_POLICY_DAYS=14
# keep 12 weekly snapshots
RETENTION_POLICY_WEEKS=12
# keep 18 monthly snapshots
RETENTION_POLICY_MONTHS=18
# keep 2 yearly snapshots
RETENTION_POLICY_YEARS=2
bsnapshot is designed to be executed ones a day. It's up to you to setup a systemd-timer or cron.
The .deb package is automatically generated via a Continuous Delivery Pipeline - please do not build packages manually!
bsnapshot is OpenSource and licensed under the Terms of Mozilla Public License 2.0. You're welcome to contribute