User Tools

Site Tools


Syncing files with external Device

With the rsync tool you can sync all files between the raspberry pi and an external device (ex. NAS) or you can just move all files to it.

I think that all users would like to move the files to an external device, because the SD-Card has not enough space to save a lot of pictures and movies.

A very interesting and nice feature is, that we can move our files trough a SSH connection.

Install rsync

First you have to install the tool

sudo apt-get install rsync

Create a SSH config file

sudo nano /home/pi/.ssh/config
Host [YourNASIPAddress]
Port [YourNASSSHPort]
User [YourNASAdminUserName]

Afterwards generate the SSH Key

(just press Enter)
ssh-copy-id -i /home/pi/.ssh/ [YourNASIPAddress]
(enter the NAS administration password)

Now rsync will work without to enter the NAS admin password everytime.

Use rsync

rsync --progress --delete --remove-source-files --rsh=ssh -avuz /home/pi/motion/motion [YourNASIPAddress]::/share/MD0_DATA/UserUpload/RaspPi/ >> /dev/null 2>&1


Defines if all files on NAS should be deleted if the files are also not available on the raspberry (sync all files).


Delete all files on the source location (raspberry), so the command will “move” the files to the NAS.

To get this job done all 30 minutes automatically I created a cronjob

sudo crontab -e
*/30 * * * * rsync --progress --delete --remove-source-files --rsh=ssh -avuz /home/pi/motion/motion [YourNASIPAddress]::/share/MD0_DATA/UserUpload/RaspPi/ >> /dev/null 2>&1
rsync.txt · Last modified: 15.04.2014 22:30 by tigermatze