Skip to content

Instantly share code, notes, and snippets.

@scorpp
Last active December 29, 2020 13:40
Show Gist options
  • Save scorpp/a221cad3358ba1cd061e to your computer and use it in GitHub Desktop.
Save scorpp/a221cad3358ba1cd061e to your computer and use it in GitHub Desktop.
Hetzner backup hook to mount Hetzner backup space
#!/bin/bash
# vzdump hook script that handles mounting of [Hetzner] backup space
# [over SFTP] and then mounting an FS image stored there.
# After backup is done backup image is remounted to ensure data synced.
# Relies on /etc/fstab entries for backup mount points and pub key auth
# for SFTP.
#
# Corresponding fstab enties:
# uXXXXXX@uXXXXXX.your-backup.de: /mnt/backup-space fuse.sshfs defaults,noauto,allow_root,_netdev 0 0
# /mnt/backup-space/image /mnt/backup ext4 noauto,defaults,loop 0 0
PHASE="$1"; shift
MODE="$1"; shift
VMID="$1"; shift
## other available variables
#DUMPDIR
#HOSTNAME
#TARFILE
#LOGFILE
if [ -n "$DEBUG" ]
then
echo " =============="
echo "PHASE ${PHASE}"
echo "MODE ${MODE}"
echo "VMID ${VMID}"
echo "DUMPDIR ${DUMPDIR}"
echo "HOSTNAME ${HOSTNAME}"
echo "TARFILE ${TARFILE}"
echo "LOGFILE ${LOGFILE}"
echo " =============="
fi
case $PHASE in
job-start)
echo "Making sure backup space and image are mounted"
mount -v /mnt/backup-space
mount -v /mnt/backup
# give FS some extra time
sleep 2
;;
backup-end|backup-abort)
echo "$(date) Force sync to backup image fs..."
umount -v /mnt/backup
mount -v /mnt/backup
echo "$(date) done"
;;
job-end)
echo "Unmount backup storage"
umount -v /mnt/backup
umount -v /mnt/backup-space
;;
*)
exit 0
;;
esac
exit 0
@scorpp
Copy link
Author

scorpp commented Jul 31, 2015

this way differential backups from https://ayufan.eu/projects/proxmox-ve-differential-backups/ work fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment