Thread (24 messages) 24 messages, 12 authors, 2012-03-01

Re: [RFC] btrfs auto snapshot

From: Ken A <hidden>
Date: 2011-08-17 14:50:34

and much easier than trying to get snapper to compile on fedora
libblocxx ?
:-)
Ken


On 8/17/2011 9:04 AM, Dave wrote:
I've already done something similar.  I take hourly, daily, weekly, and monthly
snapshots of my /home subvolume.  Here's the script I've created for this:

#! /bin/bash

if [ "$#" -ne 2 ]; then
    echo Usage $0 SNAPSHOT_PREFIX NUM_SNAPSHOTS
    exit 1
fi

SNAPS=/var/lib/btrfs-root/__snapshot/home

btrfs subvolume snapshot -r /home $SNAPS/$1_$(date +%F_%T.%N)

num_snaps=$(ls -1d $SNAPS/$1_* | sort | wc -l)

if [ "$num_snaps" -gt "$2" ]; then
    let over=$num_snaps-$2
    ls -1d $SNAPS/$1_* | head -n $over | while read s; do
       btrfs subvolume delete $s
    done
fi


Here's my crontab:
0 * * * * /usr/local/bin/snapshot hourly 6
0 0 * * * /usr/local/bin/snapshot daily 7
0 0 * * 0 /usr/local/bin/snapshot weekly 4
-- 
Ken Anderson
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help