Skip to content

Instantly share code, notes, and snippets.

@gamma
Created June 13, 2023 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamma/b7fe73ddd037779b48d59c03781021c5 to your computer and use it in GitHub Desktop.
Save gamma/b7fe73ddd037779b48d59c03781021c5 to your computer and use it in GitHub Desktop.
Create Backup from Hetzner Storage Box to Synology DSM using ActiveBackup For Business
#!/bin/bash
# Backing up a Hetzner Storage box TO the Synology DSM does not work easily due to
# the special rsync paths requhired by Hetzner which is /home as root. However, Synology
# does not allow the and requests the path // - which is basically the root. Hetzner
# not allow that in turn. This script solves the issue by being a wrapper to rsync,
# which modifies the command to reflect that change.
#
# Script is provided as is, for free, no guarantees given. Use at your own risk.
#
########################################################################################
# SETUP
# -----
# This script has to be placed into the /bin directory to work as drop-in-replacement
# For that you have to:
# cp -a /bin/rsync /bin/rsync_
# cat > /bin/rsync
# <CAT THE SCRIPT>
# chmod go+rx /bin/rsync
########################################################################################
pattern="^\w+@.*://.*$"
if [ $# -lt 1 ]; then
echo "Error: No source path provided."
echo "Usage: rsync_wrapper.sh <rsync arguments>"
exit 1
fi
modified_args=("$@") # Initialize with original arguments
for ((i=1; i<=$#; i++)); do
source="${modified_args[i]}"
if [[ $source =~ $pattern ]]; then
modified_args[i]="${source//:\/\//:\/home}"
fi
# Optional debug: Print each parameter
# echo "Parameter $i: ${modified_args[i]}"
done
# Print modified arguments
# echo "Modified arguments: ${modified_args[@]}"
# Execute the rsync_ command
/bin/rsync_ "${modified_args[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment