BLOGG
This is my "short" step-by-step instruction of how to setup a Raspberry Pi as a remote backup for your important files. The targeted audience for these notes is people that are a little bit familiar with Linux and knows how to google solutions to any gaps and issues within these notes.
With that said, I still appreciate feedback and I would like to make these notes as good and correct as possible.
A schematic of the targeted solution:

Specifications and starting point:
Raspberry Pi, a.k.a. RPi, is a model B, revision 2, 512 MB, running Raspbian.
Static IP address (192.168.1.2) is configured on RPi and a separate computer on the same network is used to connect via SSH during the entire configuration. Please google howto setup static IP in Debian.
Any commands run on/from RPi looks like this:
The file server, a.k.a. NAS, is a computer running Debian.
Commands run on/from NAS looks like this:
The external storage device is a Western Digital My Book of 1 TB.
1. Connect external disk
2. Test rsync
3. Create key pair
4. Automate backups using crontab
5. Static url to RPi
6. Configure remote router for portforward
External disk
Some small external USB disks can be powered by the RPi itself. If you have one of those, please use it and let me know how stable it is. I didn't get it to work with mine.
I'm using an old WD My Book 1 TB that I had lying around. A huge plus is that it supports spin-down which means it doesn't need to be activated all the time. Less noise produced and less power consumed at the remote location.
Note: I have about 2TB of data to backup, but in order to simplify things I choose to only backup new data using this RPi solution.
Old data has been manually backed up to a seperate (offline) HDD.
Connect the external disk.
Check available disks from within the RPi:
Identify the external disk with size approximately 1000 GB.
In my case it was /dev/sda.
Delete old partitions and create a new one using:
(Please use google for further instructions on how to use fdisk)
Note: You can keep and use old partitions if you like. But if they are Windows partitions some rsync functions may not work properly due to restricted access from Linux.
Format the partition to a Linux file system:
Create folder where to mount the disk
Mount the disk:
Check the parameters for the mount:
Enter the equivalent parameters in /etc/fstab. And add the parameter noatime to enable the disk to spin down:
Reboot and verify that the disk is mounted automatically.
rsync
install rsync on the NAS and the RPi:
Create folder on the RPi external disk to match the existing folder that is to be backed up on NAS.
Make sure that the inteded user is the owner of the directory and has write privileges.
Run rsync from NAS
Enter the password for user1@RPi when prompted.
Verify that the files have been transferred and that the specified log file is has been created and contain the corresponding data.
SSH key pair
Create the key pair:
Copy the public key to RPi:
Install the key:
Check these parameters are set in /etc/ssh/sshd_config:
Reload ssh:
The try to connect from NAS without password:
To make the RPi more secure, turn of password authentication by changing these parameters in /etc/ssh/sshd_config:
Then reload ssh:
Automatic backups
Setup crontab to run backups every day at 12:00:
Verify that it works by waiting for the time to occur and then check logs and changes on the extrernal HDD.
I had issues when path contained spaces but I think this can be easily solved by using single quotes around the path and escapeing the spaces. I.e. "\" before spaces.
Global URL to RPi
In case the location you are placing the RPi at, does not have static IP, you need to keep NAS updated on the address (once it's placed at the remote location, the address is no longer 192.168.1.2 from NAS's perspective). I solved this by using a subdomain of a domain example.com - raspberry.example.com
Then I configure RPi to update the DNS with the current IP.
Install ddclient:
Configure ddclient in accordance with your domain manager (not described here). I use Zoneedit.
Configure portforward on remote router
It is now time to place the RPi and external HDD at the remote location and finalize the setup.
First you need to make sure that the RPi IP address is ok to use in the new network. Please update the /etc/network/interfaces file with IP address and gateway address in accordance with the new network if necessary.
Once the local address (in the remote location) is setup, we need to make sure that the (remote) router sends packets that are coming from NAS to the RPi and not blocking it or sending it to any other computer in this network.
Please check the manual for the router.
This kind of setting is often found in a section called "virtual server" and "port forward".
It is port 22 on the WAN-side that needs to be forwarded to the RPi IP address (192.168.1.2) and port 22.
When this is done, please verify that you can SSH from NAS to raspberry.example.com:
If that worked, both port forwarding and ddclient works as expected.
Congratulations!
Now as final step. Update NAS crontab to use the URL instead of the local address to the RPi. I.e. rapsberry.example.com instead of 192.168.1.2.
Just wait for the crontab time of backup to occur to verify the final step.
With that said, I still appreciate feedback and I would like to make these notes as good and correct as possible.
A schematic of the targeted solution:

Specifications and starting point:
Raspberry Pi, a.k.a. RPi, is a model B, revision 2, 512 MB, running Raspbian.
Static IP address (192.168.1.2) is configured on RPi and a separate computer on the same network is used to connect via SSH during the entire configuration. Please google howto setup static IP in Debian.
Any commands run on/from RPi looks like this:
raspberry:/$
The file server, a.k.a. NAS, is a computer running Debian.
Commands run on/from NAS looks like this:
server:/$
The external storage device is a Western Digital My Book of 1 TB.
1. Connect external disk
2. Test rsync
3. Create key pair
4. Automate backups using crontab
5. Static url to RPi
6. Configure remote router for portforward
External disk
Some small external USB disks can be powered by the RPi itself. If you have one of those, please use it and let me know how stable it is. I didn't get it to work with mine.
I'm using an old WD My Book 1 TB that I had lying around. A huge plus is that it supports spin-down which means it doesn't need to be activated all the time. Less noise produced and less power consumed at the remote location.
Note: I have about 2TB of data to backup, but in order to simplify things I choose to only backup new data using this RPi solution.
Old data has been manually backed up to a seperate (offline) HDD.
Connect the external disk.
Check available disks from within the RPi:
raspberry:/$ fdisk -l
Identify the external disk with size approximately 1000 GB.
In my case it was /dev/sda.
Delete old partitions and create a new one using:
raspberry:/$ fdisk /dev/sda
(Please use google for further instructions on how to use fdisk)
Note: You can keep and use old partitions if you like. But if they are Windows partitions some rsync functions may not work properly due to restricted access from Linux.
Format the partition to a Linux file system:
raspberry:/$ mkfs.ext3 /dev/sda1
Create folder where to mount the disk
raspberry:/$ mkdir /mnt/backup
Mount the disk:
raspberry:/$ mount /dev/sda1 /mnt/backup
Check the parameters for the mount:
raspberry:/$ mount
Enter the equivalent parameters in /etc/fstab. And add the parameter noatime to enable the disk to spin down:
raspberry:/$ vi /etc/fstab
Reboot and verify that the disk is mounted automatically.
rsync
install rsync on the NAS and the RPi:
raspberry:/$ apt-get install rsync
Create folder on the RPi external disk to match the existing folder that is to be backed up on NAS.
raspberry:/$ mkdir /mnt/backup/new_pictures
Make sure that the inteded user is the owner of the directory and has write privileges.
raspberry:/$ chown -R user1:user1 /mnt/backup/new_pictures
raspberry:/$ chmod -R 755 /mnt/backup/new_pictures
raspberry:/$ chmod -R 755 /mnt/backup/new_pictures
Run rsync from NAS
server:/$ rsync -avP --delete --log-file=/home/user1/rsync-backup-pictures.log --modify-window=1 /home/user1/pictures/2014/ -e ssh user1@192.168.1.2:/mnt/backup/new_pictures/
Enter the password for user1@RPi when prompted.
Verify that the files have been transferred and that the specified log file is has been created and contain the corresponding data.
SSH key pair
Create the key pair:
server:/$ ssh-keygen -t rsa -b 2048
Copy the public key to RPi:
server:/$ scp ~/.ssh/id_rsa.pub user1@192.168.1.2:
Install the key:
raspberry:/$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
raspberry:/$ rm ~/id_rsa.pub
raspberry:/$ rm ~/id_rsa.pub
Check these parameters are set in /etc/ssh/sshd_config:
RSAAuthentication yes
PubkeyAuthentication yes
PubkeyAuthentication yes
Reload ssh:
raspberry:/$ service ssh reload
The try to connect from NAS without password:
server:/$ ssh user1@192.168.1.2
To make the RPi more secure, turn of password authentication by changing these parameters in /etc/ssh/sshd_config:
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
PasswordAuthentication no
UsePAM no
Then reload ssh:
raspberry:/$ service ssh reload
Automatic backups
Setup crontab to run backups every day at 12:00:
server:/$ crontab -e
00 12 * * * rsync -avP --delete --log-file=/home/user1/rsync-backup-pictures.log --modify-window=1 /home/user1/pictures/2014/ -e ssh user1@192.168.1.2:/mnt/backup/new_pictures/
00 12 * * * rsync -avP --delete --log-file=/home/user1/rsync-backup-pictures.log --modify-window=1 /home/user1/pictures/2014/ -e ssh user1@192.168.1.2:/mnt/backup/new_pictures/
Verify that it works by waiting for the time to occur and then check logs and changes on the extrernal HDD.
I had issues when path contained spaces but I think this can be easily solved by using single quotes around the path and escapeing the spaces. I.e. "\" before spaces.
Global URL to RPi
In case the location you are placing the RPi at, does not have static IP, you need to keep NAS updated on the address (once it's placed at the remote location, the address is no longer 192.168.1.2 from NAS's perspective). I solved this by using a subdomain of a domain example.com - raspberry.example.com
Then I configure RPi to update the DNS with the current IP.
Install ddclient:
raspberry:/$ apt-get install ddclient
Configure ddclient in accordance with your domain manager (not described here). I use Zoneedit.
Configure portforward on remote router
It is now time to place the RPi and external HDD at the remote location and finalize the setup.
First you need to make sure that the RPi IP address is ok to use in the new network. Please update the /etc/network/interfaces file with IP address and gateway address in accordance with the new network if necessary.
Once the local address (in the remote location) is setup, we need to make sure that the (remote) router sends packets that are coming from NAS to the RPi and not blocking it or sending it to any other computer in this network.
Please check the manual for the router.
This kind of setting is often found in a section called "virtual server" and "port forward".
It is port 22 on the WAN-side that needs to be forwarded to the RPi IP address (192.168.1.2) and port 22.
When this is done, please verify that you can SSH from NAS to raspberry.example.com:
server:/$ ssh raspberry.example.com
If that worked, both port forwarding and ddclient works as expected.
Congratulations!
Now as final step. Update NAS crontab to use the URL instead of the local address to the RPi. I.e. rapsberry.example.com instead of 192.168.1.2.
Just wait for the crontab time of backup to occur to verify the final step.
