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

Up sweethome3d (4.0)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 25 12:53:51 2013 +0200 (2013-04-25)
parents 90f1623aac5e
children
line source
1 #!/bin/sh
3 # Keep last 30 daily snapshots with crontab
4 # Note: do not create 2 snapshots simultaneously (break btrfs mountage)
5 #0 * * * * /usr/bin/btrfs-snapshot 5 -hourly
6 #1 0 * * * /usr/bin/btrfs-snapshot 30 -daily
7 #2 0 1 * * /usr/bin/btrfs-snapshot 12 -monthly
8 #3 0 1 1 * /usr/bin/btrfs-snapshot 99 -yearly
10 btrfs_list()
11 {
12 awk '/ btrfs / { if (fs[$1] == "") { fs[$1] = $2; print $2 }}' \
13 < /proc/mounts
14 }
16 which btrfs > /dev/null && for root in $(btrfs_list) ; do
17 dir=${root%/}/.snapshots$2
18 [ -d $dir ] || mkdir $dir
19 cd $dir
20 i=0
21 for s in $(ls -r); do
22 [ $((i++)) -ge ${1:-10} ] && btrfs subvolume delete $s
23 done
24 btrfs subvolume snapshot -r / $(date +%Y%m%d%H%M%S)
25 done