Last active
December 29, 2020 13:40
-
-
Save scorpp/a221cad3358ba1cd061e to your computer and use it in GitHub Desktop.
Hetzner backup hook to mount Hetzner backup space
This file contains 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/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: | |
# [email protected]: /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 |
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
based off http://www.blunix.org/howto-use-hetzner-backup-space-with-rsync/ and https://www.dim13.org/Backup-Proxmox-Containers-to-FTP