wok view btrfs-progs/stuff/btrfs-snapshot @ rev 14774
Up xorg-libXi (1.7.1.901), see http://www.x.org/wiki/Development/Security/Advisory-2013-05-23
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jun 30 10:36:53 2013 +0200 (2013-06-30) |
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