Last active
January 25, 2023 15:02
-
-
Save zvpunry/af667816d63df089cd34f81458598b6f 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
This file contains hidden or 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/sh | |
# Original source: https://gist.github.com/wwerther/1306189 | |
# Original documentation: http://web.archive.org/web/20190910001551/http://it.werther-web.de/2011/10/23/migrate-rsnapshot-based-backup-to-btrfs-snapshots | |
# Modified version: https://gist.github.com/zvpunry/af667816d63df089cd34f81458598b6f | |
# | |
# Arg 1: -rf | |
# Arg 2: /testbtrfs/backups/hourly.4/ | |
# echo 1: $1 2: $@ | |
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |
# Try to delete the given path with btrfs subvolume delete first | |
# if this fails fall back to normal rm | |
if test "$1" = "-rf" -a -z "$3" | |
then | |
btrfs property set -ts "$2" ro false | |
btrfs subvolume delete -C "$2" > /dev/null || rm -rf "$2" | |
else | |
rm "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment