Rsync backups to Synology DS112
So at work I am fed up with feeding tapes into the server every week, and we have decided to use BackupAssist software to create a local backup on a NAS drive, and an offsite backup with another NAS drive at my house using Rsync.
BackupAssist has the interesting ability to only store changes in files, so the backup doesn't get enormous, but you can drag any historical copy of any file back from the NAS drive without using special software. How it does this, I don't know (I haven't tried it yet, so maybe it doesn't do it.)
I have got the local backup running, only 2 nights so far, but that was fairly easy.
The Rsync backup however, was a different story...
Rsync is a cunning bit of software designed for backups over the net with limited bandwidth. We only have 1Mbps upload at work, if we tried to backup the whole thing it would take several weeks. But if you start off with a full "seed" backup, Rsync just sends the changed portions of files (not even whole changed files) so in theory it could all work.
The Synology DS112 drive we are using has a built in Rsync server, so I enabled that, and pointed the appropriate ports 22 and 873 at the box.
Unfortunately BackupAssist could see the DS112 but could not set up SSH to it - I kept getting the error "cannot create folder home\admin\.ssh"
This turned out to be because SSH and/or telnet were not enabled on the DS112.
Then BackupAssist complained that the "backup module" (folder) was read only. To fix this I had to set the login name used by BackupAssist to "root" (with the Admin password).
Then I was able to do a test backup. The curious thing... the backup does not appear on the DS112 if I log on to it and look at it - so where is it?
So, on further investigation, it's not there... if you logon as root, the user has no write permission on the drive so although the files were tranferred, they were not actually written. But the rsync application will only accept logon as "root" or "rsync". I tried creating the user "rsync" but then we were back to the first error.
Many forum posts on the net suggest editing the rsyncd.conf file which allows you to set other users. So I telnetted into the dS112, managed to remember how to work Unix, edited the file... but no, Admin still not allowed - the read only error.
Then a forum post suggested that rsyncd.conf only applies if the rsync daemon is being used - which it isn't if you use rsync over SSH. So in the end I have set it up for "rsync daemon with SSH tunnelling", using Admin as user (which has full rights to the drive). This, finally, appeared to work.
...and it worked reliably for over a year, but then we had a power glitch at our house and something has happened to the Synology box.
First problem, it had turned off SSH and Telnet. That was easily fixed.
Next problem, the rsync server would no longer connect giving the error below...
channel 2: open failed: connect failed: Connection refused
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(760) [sender=3.0.7]
I noticed that the owner of all the folders on the hard drive was now set to "0" where it should be set to "admin". So I changed all those back. But no change.
After some head scratching, we decided that the rsync daemon was probably not running. By connecting to the box using SSH (login as root) and using the ps command, this showed that rsync was not in the list of running processes. So I typed "rsync --daemon" to start rsync manually, and got the message.
failed to create pid file /var/run/rsyncd.pid: File exists
So I went to the folder /var/run, and did rm rsyncd.pid to delete the offending file
Then rsync --daemon again... and voila, rsync was running, and Backupassist could now talk to it again. Hooray!! Presumably the rsync process in crashing out had failed to delete the file. Although you would have thought that rsync could just delete the file itself on startup...
Time for a UPS I think.
Another problem: the backup sticks on "sending incremental file list". This seems to be due to the Synology box getting a bit mixed up and needing a reboot (if you ps then it is running about 50 copies of Rsync). It wouldn't reboot or shut down (blue power light just constantly flashes) so I had to pull the power on it then get rsync going again using the procedure above.
Then the Synology box updated to DSM6 and everything stopped again. There are a few problems here. It disables the Home folders and you have to enable them again by going to Control Panel - User - Advanced - Enable User Home Service. Also the root user is disabled which rsync uses, on telnet you can get to root by logging in as admin then going sudo -i.
Also ps no longer seems to show all services running, you need ps -ef to show them all.
So... then the disk drive died. Gotta love Seagate, had loads of Seagate drives failed. This basically means reinstalling the NAS from scratch and now it doesn't work again.
First problem get
Permission denied (publickey,password). when testing the connection
To fix this login via SSH and do
chmod 755 /volume1/homes/my-nas-user
(This restricts permission to the key files to only that user - SSH requires this or it won't allow login)
Then I had to alter/etc/ssh/sshd_config to add a section for the rsync user
Match User rsync