blob: e3377ca47439f1082f4328d8aa0fe3e4b4e28b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/bin/bash
set -e
SNAP_ID=$1
SNAP_MOUNTPOINT="$2"
SNAP_NAME="$3"
SNAP_DEST="$4"
SNAP_ORIG_PATH="$5"
if ! test -e $SNAP_MOUNTPOINT
then
echo "Snapshot at $SNAP_MOUNTPOINT was already removed"
exit 0
fi
TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | tr -s " " | cut -d" " -f2)
if [[ $TYPE == "" ]]
then
if btrfs subvolume list -o "$SNAP_MOUNTPOINT" > /dev/null 2>&1
then
TYPE="btrfs"
fi
fi
if [[ $TYPE == "btrfs" ]]
then
btrfs subvolume delete "$SNAP_MOUNTPOINT"
else
echo "Cannot remove snapshot at $SNAP_MOUNTPOINT. File system type $TYPE not supported."
exit 1
fi
exit 0
|