Synology rsync Backup
Tagged with: development, personal, travel
One of the basic tenets of doing backups from nixie type machines is using rsync to accurately sync your files from one place to the other. Although it is possible to run an rsync daemon, that's not how most people use it, so that's how I did not do it, even though setting up an rsync daemon is just a few clicks of work.
Setting up SSH
Normally we'd like to set up a key-pair to take care of the authentication. So, that's just what we're going to do. On the Synology create a user and add it to the Administrators group.
ssh into the Synology and using
sudo -i switch over to root-access.
At least in my case this was needed to create the user-dir at
/var/services/homes/[username], because that's where it was looking, but not
actually existing. A quick
chmod [username] /var/services/homes/[username]
later and I was ready to setup the public key access!
mkdir ~/.ssh chmod 0700 ~/.ssh touch ~/.ssh/authorized_keys chmod 0644 ~/.ssh/authorized_keys
As a final step I needed to add my public key to the authorized keys of course.
echo ssh-rsa AAAASomethingyMajiggy firstname.lastname@example.org >> authorized_keys
exit and then going back in on the SSH connection, which should now go
without an ask for a password :)
Running an rsync
So, essentially, everything should be up and running now. We know
installed on our Synology, so that part's sorted. Combined with having a working
SSH key-based login, we should just have it all running straight up.
rsync -avz -e ssh --rsync-path="/bin/rsync" --progress /home/localuser/testfile.txt [username]@192.168.0.1:/volume1/Backup/temp
You have to be a little round-about in stringing this command together... For normal connections it'd pick up the rsync binary without fail, for some reason the Synology server setup is just strange enough not to work. However, when providing the right info, rsync is more than able to pick it up.
So, to dissect the above command. The
avz attributes are rather run of the
mill, archive mode should preserve file-attributes, verbosity for extra feedback
and finally zip the transfer to reduce bandwidth, I suppose that one's often not
so useful when on the LAN.
--rsync-path attribute is crucial here, don't quite understand why, but
by pointing it to the rsync binary my Synology user has access to, everything
works. If I leave it out, I only get
Permission denied, please try again..