fi
# Error tolerant grep
-tgrep()
-{
+tgrep() {
grep "$@"
return 0
}
-do_backup()
-{
+do_backup() {
set -o pipefail
echo "$(date): rsync $RSYNC_OPTS $SRC $DEST/tmp/"
rsync $RSYNC_OPTS "$SRC" "$DEST/tmp/" 2>&1 | tgrep -v -E 'vanished|some files'
set +o pipefail
}
-
-do_init()
-{
+do_init() {
# Safety net (4 slashes just in case)
case "$DEST" in
/|//|///|////) exit 666 ;;
cd "$DEST" || exit 668
}
-do_prune()
-{
+do_prune() {
local old="`ls | grep -v tmp | head -n -$SNAPSHOTS`"
if [ ! -z "$old" ]; then
echo "$(date): Removing oldest snapshot(s): $old..."
fi
}
-do_link()
-{
+do_link() {
local newest=`ls | grep -v tmp | tail -n 1`
if [ -d "$DEST/tmp" ]; then
echo "$(date): Continuing with pre-existing snapshot $DEST/tmp"
fi
}
-do_test()
-{
+do_test() {
# TODO: test for free space and free inodes in the $DEST filesystem
block_size=`stat --file-system --format "%S" "$DEST"`
free_blocks=`stat --file-system --format "%f" "$DEST"`