Skip to content

Instantly share code, notes, and snippets.

@jzuijlek
Created July 18, 2016 06:36
Show Gist options
  • Save jzuijlek/8f71fc43757b272de06e994766cb8b24 to your computer and use it in GitHub Desktop.
Save jzuijlek/8f71fc43757b272de06e994766cb8b24 to your computer and use it in GitHub Desktop.
a small shell script that can be used within rsnapshot as cmd_rm. It provides snapshots generated with btrfs instead of hard-links
#!/bin/sh
# Arg 1: -rf
# Arg 2: /testbtrfs/backups/hourly.4/
# echo 1: $1 2: $@
# Try to delete the given path with btrfs subvolume delete first
# if this fails fall back to normal rm
if [ "$1" = "-rf" -a "$3" = "" ]; then
# "trying to delete with btrfs"
btrfs subvolume delete $2
error=$?
if [ $error -eq 13 ]; then
# EC 13 => The directory specified is no subvolume
rm $@
elif [ $error -ne 0 ]; then
echo Error while deleting with btrfs $?
fi
else
rm $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment