Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Created April 16, 2017 04:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pigeonflight/cd1e35e997272b9a3dcee54791bb0b86 to your computer and use it in GitHub Desktop.
Save pigeonflight/cd1e35e997272b9a3dcee54791bb0b86 to your computer and use it in GitHub Desktop.
Script to mount hetzner backup space

Setup

All commands here are run as root Install sshfs and autofs :

apt-get update
apt-get install sshfs autofs

Ensure you have an ssh key:

ssh-keygen

export backup_user=uXXXXXXX

have your backup space password ready (you can find it in your hetzner controlpanel for your server). Then run the following command:

bash mount-my-backup-space.sh

You should now be able to access your backup space at /mnt/sshfs/my-backup-space

ssh-keygen -e -f .ssh/id_rsa.pub | grep -v "Comment:" > .ssh/id_rsa_rfc.pub
cat .ssh/id_rsa_rfc.pub >> backup_authorized_keys
# set this to name of your backup user usually something like u432424
# we then send the new key to the backup service
# this is a funny way of sending a command but necessary because
# of lack of shell access to the backup space, probably so people don't
# try to use the backup space to run additional services
echo mkdir .ssh | sftp $backup_user@$backup_user.your-backup.de
# don't worry if "mkdir .ssh" fails, it means it exists already
scp backup_authorized_keys $backup_user@$backup_user.your-backup.de:.ssh/authorized_keys
mkdir -p /mnt/sshfs
mkdir -p /etc/auto.master.d
echo "/mnt/sshfs /etc/auto.sshfs uid=0,gid=0,--timeout=30,--ghost" > /etc/auto.master.d/sshfs.autofs
echo "my-backup-space -fstype=fuse,rw,nodev,nonempty,allow_other,reconnect,max_read=65536 :sshfs\#$backup_user@$backup_user.your-backup.de\:/" > /etc/auto.sshfs
# reload autofs
service autofs reload
@missinglink
Copy link

worked for me, although I found mounting a CIFS share as per the Hetzner docs was more performant.

@pigeonflight
Copy link
Author

@missinglink good to know

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