1
0
mirror of https://github.com/nachoparker/btrfs-snp.git synced 2024-12-23 01:04:12 +01:00
Automatic BTRFS snapshots made simple
Go to file
Zachary Smith 4a3b653342
Add margin for time comparison. (#7)
* Add margin option for time comparison.

* Update btrfs-snp

* Update btrfs-snp

Co-authored-by: nachoparker <nacho@ownyourbits.com>
2020-03-20 04:08:32 +00:00
btrfs-snp Add margin for time comparison. (#7) 2020-03-20 04:08:32 +00:00
LICENSE Initial commit 2017-12-27 19:08:32 +01:00
README.md support absolute paths 2018-11-11 12:42:20 -07:00

btrfs-snp

Create BTRFS snapshots, manually or from cron.

Usage

# btrfs-snp
Usage: btrfs-snp <dir> (<tag>) (<limit>) (<seconds>) (<destdir>)

  dir     │ create snapshot of <dir>
  tag     │ name the snapshot <tag>_<timestamp>
  limit   │ keep <limit> snapshots with this tag. 0 to disable
  seconds │ don't create snapshots before <seconds> have passed from last with this tag. 0 to disable
  destdir │ store snapshot in <destdir>, path absolute or relative to <dir>

Examples

Manual

Snapshot of home

# btrfs-snp /home

Tagged snapshot of root

# btrfs-snp / preupgrade

Tagged snapshot of root, but keep maximum 10

# btrfs-snp / preupgrade 10

Cron

Hourly snapshot for one day, daily for one week, weekly for one month, and monthly for one year.

# cat > /etc/cron.hourly/btrfs-snp <<EOF
#!/bin/bash
/usr/local/sbin/$BIN /home hourly  24 3600
/usr/local/sbin/$BIN /home daily    7 86400
/usr/local/sbin/$BIN /home weekly   4 604800
/usr/local/sbin/$BIN /     weekly   4 604800
/usr/local/sbin/$BIN /home monthly 12 2592000
EOF
chmod +x /etc/cron.hourly/btrfs-snp

Inspired by btrfs-snap by Birger Monsen

More at ownyourbits.com