Created
June 13, 2023 06:12
-
-
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
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 | |
# 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