wok view btrfs-progs/stuff/btrfs-snapshot @ rev 13631

Up: grsync (1.2.2)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Nov 15 18:50:18 2012 +0100 (2012-11-15)
parents 09fb684d4984
children 9584476eeb17
line source
1 #!/bin/sh
3 # Keep last 30 daily snapshots with crontab
4 #0 * * * * /usr/bin/btrfs-snapshot 5 -hourly
5 #0 0 * * * /usr/bin/btrfs-snapshot 30 -daily
6 #0 0 1 * * /usr/bin/btrfs-snapshot 12 -monthly
7 #0 0 1 1 * /usr/bin/btrfs-snapshot 99 -yearly
9 btrfs_list()
10 {
11 awk '/ btrfs / { if (fs[$1] == "") { fs[$1] = $2; print $2 }}' \
12 < /proc/mounts
13 }
15 which btrfs > /dev/null && for root in $(btrfs_list) ; do
16 dir=${root%/}/.snapshots$2
17 [ -d $dir ] || mkdir $dir
18 cd $dir
19 i=0
20 for s in $(ls -r); do
21 [ $((i++)) -ge ${1:-10} ] && btrfs subvolume delete $s
22 done
23 btrfs subvolume snapshot -r / $(date +%Y%m%d%H%M%S)
24 done