Feed on
Posts
Comments

During my CeBIT 2010 visit I stumbled upon a new offer from Strato: HiDrive. That’s an online storage solution starting with 100GB without traffic limitations. Supported protocols are WEBDAV(S), CIFS/SMB (even via openvpn!), FTP, SCP and rsync. As a special bonus to CeBIT visitors they offered the 100GB entry package for 1€ in the first year.

I use this storage as a backup solution of my home file server. As a benefit I can mount this storage from anywhere and access my files faster than using a VPN to my home server.

Preparations on your HiDrive

Activate rsync support for your volume. Go to Settings, Account and select Account settings from the dropdown menu of your user. Make sure the rsync protocol is turned on.

Upload your ssh public key so this little script can be used password-less. Your public key is normally located in ~/.ssh/id_dsa.pub on your Linux box. You need the public key of the user you start the script with. You find the option to upload our public key in the same dropdown menu you used for enabling rsync.

The bash / rsync script

We will create the backup script in /root/hidrive_bck.sh but you can save it wherever you want. Edit the script using

nano -w /root/hidrive_bck.sh

# HiDrive Config

HIDRIVE="rsync.hidrive.strato.com"
HIDRIVEUSER="your_user"
TARGET="/users/"$HIDRIVEUSER"/backup/"
SUBJECT="Backup_failed!"
MAILTO="your@email.com"
ERROR="/etc/hidrivebck/error.txt"
INCLUDE="/etc/hidrivebck/include"
EXCLUDE="/etc/hidrivebck/exclude"

RSYNC=/usr/bin/rsync
RSYNC_OPTIONS="-arz --delete-after --ignore-errors -e ssh"
CAT=/bin/cat
MAIL=/usr/bin/mail
CHECK_REMOTE=`ping -c1 $HIDRIVE | grep packet | awk '{print $4}'`
SOURCE="/path/to/your/files/"

#

if [ $CHECK_REMOTE == 1 ]; then
  $RSYNC $RSYNC_OPTIONS $SOURCE $HIDRIVEUSER@$HIDRIVE:$TARGET --files-from=$INCLUDE --exclude-from=$EXCLUDE
else
  $MAIL $MAILTO -s $SUBJECT < $ERROR
fi

You need to edit your HiDrive user name, your email address and your source directory. If you use a Linux distribution other than Debian / Ubuntu make sure you enter the correct path to the used commands.

Now create /etc/hidrivebck and create your config files:

mkdir /etc/hidrivebck
nano -w /etc/hidrivebck/include

/dir1
/dir2
/dir3

The include file lists all directories you want to include in your backup starting in the path you specified with the SOURCE parameter.

nano -w /etc/hidrivebck/exclude

/largedir

The exclude file contains all directories you don’t want to backup. Directories containing large media files for example.

nano -w /etc/hidrivebck/error.txt

Backup to HiDrive failed!

That’s the text mailed to you in case of an error. You need a working mailsetup for this. Now we’re almost done. Make your script executable and fire it up:

chmod +x /root/hidrive_bck.sh
/root/hidrive_bck.sh

You may have to enter your password even if you’ve uploaded your public key. It seems Strato doesn’t actitvate uploaded public keys instantly.

The first run may need a lot of time but due to the efficiency of rsync all further backups will be fast enough. You can use this backup script with cron for a fully automated backup.

5 Responses to “Strato HiDrive as Linux backup with rsync”

  1. remke says:

    :(( not yet implemented in The Netherlands
    (called with strato NL…)

  2. remke says:

    Found myself an alternative:
    http://www.datastorageunit.com/support-1

    🙂
    ~remke

  3. Kai says:

    Never heard of them.. are they trustworthy?

  4. chris says:

    Hi!

    I have modified your script in such a way that it also works if the hostname is not resolvable. With your script, I get a script error on Debian Squeeze.

    Thanks anyway for your script!

    ping -q -c1 $HIDRIVE &> /dev/null

    if [ “$?” -gt 0 ]; then
    $MAIL $MAILTO -s “$SUBJECT” < $ERROR
    else
    $RSYNC $RSYNC_OPTIONS $SOURCE $HIDRIVEUSER@$HIDRIVE:$TARGET –files-from=$INCLUDE –exclude-from=$EXCLUDE
    fi

  5. Andy says:

    perfect.. many thanks

    people may need

    ssh-keygen -t dsa

    if they dont have keys yet

Leave a Reply