Files
borg_mount/umount_backup.sh

45 lines
1.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Script to unmount QCOW2 disk image and Borg backup vault
# Created: 2025-10-07
BORG_MOUNT="/mnt/restore"
QCOW2_MOUNT="/mnt/qcow2"
echo "=== Unmounting Backup System ==="
# Unmount QCOW2 filesystem
if mountpoint -q "$QCOW2_MOUNT"; then
echo "Unmounting $QCOW2_MOUNT..."
umount "$QCOW2_MOUNT"
echo "✓ QCOW2 filesystem unmounted"
else
echo " $QCOW2_MOUNT is not mounted"
fi
# Deactivate LVM volume group
if vgs vgdata &>/dev/null; then
echo "Deactivating LVM volume group..."
vgchange -an vgdata 2>/dev/null || true
echo "✓ LVM volume group deactivated"
fi
# Disconnect NBD device
if [ -b /dev/nbd0 ]; then
echo "Disconnecting NBD device..."
qemu-nbd --disconnect /dev/nbd0
echo "✓ NBD device disconnected"
fi
# Unmount Borg vault
if mountpoint -q "$BORG_MOUNT"; then
echo "Unmounting Borg vault..."
borg umount "$BORG_MOUNT"
echo "✓ Borg vault unmounted"
else
echo " Borg vault is not mounted"
fi
echo ""
echo "Done! All backups unmounted."