Created
December 26, 2013 12:25
-
-
Save Snigelson/8133202 to your computer and use it in GitHub Desktop.
Cron job handler for btrfs rotate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /etc/btrfsrotate.cron | |
set -e | |
set -u | |
function die { | |
echo "Error: $2" >&2 | |
exit $1 | |
} | |
[ -z ${1-} ] && die 1 "Usage: $0 <periodicity>" | |
type=$1 | |
list=`eval "echo \\$${type}"` | |
list=`eval "echo ${list}"` | |
for volume in $list | |
do | |
volname=${volume%%,*} | |
keep=${volume##*,} | |
/usr/local/sbin/btrfsrotate -b "$volname" -d "`dirname $volname`" -c "$keep" -t "$type" -r -s "$suffix" ||: | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is used by btrfsrotate.cron to determinne what subvolumes | |
# to rotate. | |
# | |
# name specifies which script is executed. For instance, if | |
# btrfsrotate.cron.weekly is run, volumes are read from weekly. | |
# | |
# volumes are specified as <mount point>,<num to keep> and are | |
# separated by spaces. For example: | |
# | |
# weekly="/mnt/root/home,6 /mnt/root/volume,4" | |
# | |
# This file is sourced, so scripting is possible. | |
# Specify what to do with which subvolume. The variable name | |
# corresponds to the parameter to btrfsrotate.cron. | |
hourly="" | |
daily="" | |
weekly=/mnt/root/{root,home,db,ftp,home,lxc,puppet,www},6 | |
monthly=/mnt/root/{root,home,db,ftp,home,lxc,puppet,www},12 | |
yearly="" | |
# Specify suffix for snapshots. Preferrably date or such. | |
suffix=`/bin/date +%y%m%d-%H%M` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment