-
-
Save MegalodonBite/b0876d86e6d9698710e1afe9749f271e to your computer and use it in GitHub Desktop.
Script for using borg-backup with Hetzner storagebox
This file contains hidden or 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
#!/usr/bin/env bash | |
########## Configuration ########## | |
SSH_PASSWD="" # SSH password of the storagebox | |
BORG_USER="" # Storagebox user | |
BORG_SERVER="xxx.your-storagebox.de" # Storagebox | |
BORG_REPO="~/borg" # Borg repository on the storagebox | |
FILES="/home /opt" # Files to backup (space separated) | |
################################### | |
BORG="${BORG_USER}@${BORG_SERVER}:${BORG_REPO}" | |
ARCHIVE_NAME="$(date)" | |
export BORG_RSH="sshpass -p $SSH_PASSWD ssh -o StrictHostKeyChecking=no -p 23" | |
export BORG_PASSPHRASE="" | |
if [ "$1" == "init" ]; then | |
borg init -e repokey-blake2 $BORG | |
fi | |
if [ "$1" == "delete" ]; then | |
borg delete $BORG | |
fi | |
if [ "$1" == "export_key" ]; then | |
borg key export $BORG /dev/stdout | |
fi | |
if [ "$1" == "run" ]; then | |
borg create --progress $BORG::"$ARCHIVE_NAME" $FILES | |
touch /var/last_backup | |
fi | |
if [ "$1" == "list" ]; then | |
borg list $BORG | |
fi | |
if [ "$1" == "mount" ]; then | |
sudo mkdir -p /mnt/borg | |
sudo chown $(whoami) /mnt/borg | |
borg mount $BORG /mnt/borg | |
fi | |
if [ "$1" == "unmount" ]; then | |
borg umount /mnt/borg | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment