fix show delete list in dry run mode

master
Marc Wäckerlin 7 years ago
parent 392f4e2046
commit 642780604f
  1. 10
      btrfs-snapshots.sh

@ -101,6 +101,10 @@ for fs in ${BTRFS_VOLUMES}; do
date="-$(date +%Y-%m-%d-%H-%M)" date="-$(date +%Y-%m-%d-%H-%M)"
target="${name}snapshot${periodity}" target="${name}snapshot${periodity}"
if test -n "$device"; then if test -n "$device"; then
if mount | grep -q " on $TMP_MNT type "; then
sudo umount "$TMP_MNT"
fi
sudo mount "$device" "$TMP_MNT"
if test $dryrun -eq 1; then if test $dryrun -eq 1; then
echo -e "→ \e[1mbackup ${subvol:+subvol $subvol of }$fs on $device\e[0m" echo -e "→ \e[1mbackup ${subvol:+subvol $subvol of }$fs on $device\e[0m"
echo " " mount "$device" "$TMP_MNT" echo " " mount "$device" "$TMP_MNT"
@ -112,18 +116,14 @@ for fs in ${BTRFS_VOLUMES}; do
fi fi
echo " " umount "$TMP_MNT" echo " " umount "$TMP_MNT"
else else
if mount | grep -q " on $TMP_MNT type "; then
sudo umount "$TMP_MNT"
fi
sudo mount "$device" "$TMP_MNT"
sudo btrfs subvolume snapshot "${TMP_MNT}${subvol}" "${TMP_MNT}${target}${date}" sudo btrfs subvolume snapshot "${TMP_MNT}${subvol}" "${TMP_MNT}${target}${date}"
#if test -n "$del"; then #if test -n "$del"; then
# for f in $(ls -1 "${TMP_MNT}${target}${date}"-* | tail -n +"$del"); do # for f in $(ls -1 "${TMP_MNT}${target}${date}"-* | tail -n +"$del"); do
# sudo btrfs subvolume delete "$f" # sudo btrfs subvolume delete "$f"
# done # done
#fi #fi
sudo umount "$TMP_MNT"
fi fi
sudo umount "$TMP_MNT"
else else
echo "ERROR: no device found for $fs" 1>&2 echo "ERROR: no device found for $fs" 1>&2
exit 2 exit 2

Loading…
Cancel
Save