RSync to Synology

djb

Explorer
Joined
Nov 15, 2019
Messages
76
Hello everyone,
I'm using TrueNAS-12.0-U5.1 without issues. The server is small for personal use, 2X4TB in mirror, approximately 50% used space.

I used to have a Synology DS218 , but now i switch my main fileserver to the TrueNAS system.
What is the procedure to RSync the Data to the Synology ? I notice that synology cannot do modules, so can be done with SSH?

I have made all the settings to synology to accept SSH from a user "truenazz", and test it with putty, so i consider Synology as ok.

My issue is when i go to setup the rsync task on truenas, i got some strange error saying : "In order to use rsync over SSH you need a user with a private key (DSA/ECDSA/RSA) set up in home dir. " So i set a home dir for the user truenazz and created SSH Keypair under System->SSH Keypairs. This procedure gave me a private key and a public key, but are not attached to the user truenazz. I'm stuck now i don't know what's next. Where i have to use the key and how to follow up?

Anyone with experience can suggest something ? Thank you.
 
Joined
Oct 22, 2019
Messages
3,641
and created SSH Keypair under System->SSH Keypairs. This procedure gave me a private key and a public key, but are not attached to the user truenazz.
I believe it's only used for the replication tasks between servers. I found it's not tied directly to "root" or any created user account.

You can run, from within your TrueNAS server, ssh-keygen to generate a private-public key pair. Then copy/import the public key to Synology.

As the user truenazz, something like,
ssh-keygen -f ~/.ssh/truenazz-rsync

Make sure the .ssh directory is read-write-traverse only for the user, not for group or world.

chmod 700 ~/.ssh

Then use ssh-copy-id or any method you prefer to add the public key (i.e, truenazz-rsync.pub) to the Synology user's authorized_keys. (Not familiar with Synology nor if it restricts what user has SSH access.)

The rest is a matter of making sure the user has read/write access to the destination path in Synology, and Rsync will take care of the rest.
 
Last edited:

djb

Explorer
Joined
Nov 15, 2019
Messages
76
I believe it's only used for the replication tasks between servers. I found it's not tied directly to "root" or any created user account.

You can run, from within your TrueNAS server, ssh-keygen to generate a private-public key pair. Then copy/import the public key to Synology.

As the user truenazz, something like,
ssh-keygen -f ~/.ssh/truenazz-rsync

Make sure the .ssh directory is read-write-traverse only for the user, not for group or world.

chmod 700 ~/.ssh

Then use ssh-copy-id or any method you prefer to add the public key (i.e, truenazz-rsync.pub) to the Synology user's authorized_keys. (Not familiar with Synology nor if it restricts what user has SSH access.)

The rest is a matter of making sure the user has read/write access to the destination path in Synology, and Rsync will take care of the rest.

Thanks for your comment. i have opened a synology support ticket since they describe a method in their documentation that is not exists on the model i have. Also there is a thread on Lawrence systems forum for this, seems complicated. I wish the did the "module" setup like Truenas. peace of mind.

I fix it, or i throw it away.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
Depending on what you are backing up you could just use Synology ActiveBackup instead of rsync
 

djb

Explorer
Joined
Nov 15, 2019
Messages
76
Depending on what you are backing up you could just use Synology ActiveBackup instead of rsync

My backup is very simple, from 1 SMB share to 1 SMB share, (Truenas to Synology) [i have tried all the options in Synology]
Synology Apps are constructed such a way that are supporting 100% other Synology devices, but not general devices.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
Synology Active Backup has an SMB share backup - that I assume is on your synology. Its not on all of them but a 218 is quite modern.

Turns out that the 218 doesn't support BTFRS, so no ActiveBackup for Business.

Suggestion - you could mount a remote CIFS Folder in File Station which would at least get the data appearing accessible to the 218. YOu could then potentially use HyperBackup from the mounted folder to a real folder - maybe
 
Last edited:
  • Like
Reactions: djb

djb

Explorer
Joined
Nov 15, 2019
Messages
76
There is no Active Backup on DS218.
There is Hyper Backup which is a backup app for the Synology to another location (so is ok if using it as primary) but is not working if is secondary, like my case.
And also Hyper Backup Vault which makes the device backup destination for another Synology device (only).

So i don't see any progress, shame for this brand.
 
Joined
Oct 22, 2019
Messages
3,641
Have you tried the manual SSH route on Synology's side, and then use TrueNAS's Rsync Task to run scheduled rsyncs over SSH to the Synology server?
 

djb

Explorer
Joined
Nov 15, 2019
Messages
76
Have you tried the manual SSH route on Synology's side, and then use TrueNAS's Rsync Task to run scheduled rsyncs over SSH to the Synology server?

I would try that, but seems that i need to setup the public key and private key for the servers. I also open a ticket and send me that proceedure. Seems complicated to me. Is not supporting RSync module like Truenas.


The TrueNAS Rsync Tasks will require Key Authentication.
Here are some Instructions on how to set up RSA Key Authentication with your NAS:
  1. Generate an RSA key pair id_rsa (private key) and id_rsa.pub (public key) on SSH client computer using PuttyGen (for Windows 7 PC)1 or ssh-keygen (For Windows 10 PC, Mac and Linux)2. If the RSA key pair will be used for automation or password-less login, do not set up a passphrase on the private key.
  2. Upload the generated public key id_rsa.pub to the .ssh folder under the account's home folder on NAS, such as /root/.ssh (for root) or /volume1/homes/admin/.ssh (for admin).
  3. Append the public key to the authorized_keys file on NAS using the following command:
    cat /PATH_TO/id_rsa.pub >> /PATH_TO_HOME_FOLDER/.ssh/authorized_keys
  4. Import the private key into desired applications, such as FileZilla or WinSCP.3
  5. Make sure the permission of the homes shared folder is not changed.4 Run the following command to restore the default permission:
    synoshare --set_share_default_acl homes
  6. Make sure the permission of root’s home folder (/root) and the .ssh folder (/root/.ssh) and the permission of authorized_keys is 700.
  7. Make sure the owner of the .ssh folder and all items within it is the desired user (root or any account with administrative privilege).
    chown -R USER_NAME /PATH_TO_HOME_FOLDER/.ssh
 

djb

Explorer
Joined
Nov 15, 2019
Messages
76
Synology Active Backup has an SMB share backup - that I assume is on your synology. Its not on all of them but a 218 is quite modern.

Turns out that the 218 doesn't support BTFRS, so no ActiveBackup for Business.

Suggestion - you could mount a remote CIFS Folder in File Station which would at least get the data appearing accessible to the 218. YOu could then potentially use HyperBackup from the mounted folder to a real folder - maybe

Nice idea to mount the NFS, so i tried that. unfortunetely is not accepting to mount NFS share with data inside, is giving error that is not empty (it should be empty).
The reason active backup doesn't existis, is not the btrfs (btrfs is supporting). According to synology support ticket, is because of the ARM cpu on DS218.
 

cdnboy75

Cadet
Joined
Nov 17, 2021
Messages
2
Thanks to this thread I almost have the RSync working - keys are being accepted and I can complete the setup
But when I go to run the task it fails. Can't seem to find the logs to give me something more meaningful
If I turn on the remote path validate I do get:
Disconnect Error[ error code 14 ] was generated when trying to communicate with remote host 192.168.50.10 and remote user root.
So likely what the issue is just not sure what the cause is. I can SSH as the root user from the TrueNAS to the Synology no issue with no password. But it would is revolver@192.168.50.10 (which is the admin user on the NAS)
 

djb

Explorer
Joined
Nov 15, 2019
Messages
76
Thanks to this thread I almost have the RSync working - keys are being accepted and I can complete the setup
But when I go to run the task it fails. Can't seem to find the logs to give me something more meaningful
If I turn on the remote path validate I do get:
Disconnect Error[ error code 14 ] was generated when trying to communicate with remote host 192.168.50.10 and remote user root.
So likely what the issue is just not sure what the cause is. I can SSH as the root user from the TrueNAS to the Synology no issue with no password. But it would is revolver@192.168.50.10 (which is the admin user on the NAS)
Hello my friend. i didn't make any more trials with Rsync. I just blame synology for cutting on options to make you use another synology for backups.

Depending on the Synology model you have and if it supports Activesync, you can go with that.
For example on the smaller models and DS218 (as i accidently have) there is no Activesync supported because of the CPU.

My latest workaround, is to make on Synology an FTP or SFTP user for Truenas, with appropriate rights on the share for backup.
Then go to Truenas and setup CLOUDSYNC option to FTP, by using the credentials of the Synology. You have to add credentials in another menu on Truenas. Finally, you can set frequency and schedule etc for the sync to execute. End of story :)
 

cdnboy75

Cadet
Joined
Nov 17, 2021
Messages
2
Oh wow. I didn't get the other to sort of work. But this morning did your CloudSync option - that is more flexible. Thank you.
Basically I want to sync photos between the systems and Active Backup added extra stuff to the folders I wanted to use. I am trying to sync my PhotoPrism on one server to Moments on the other. Split up the horsepower and add another backup layer. It is still processing so lets see how it looks when it comes over. The CloudSync is a much better option thank you - lots more options there. In a way it seems hidden
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
Webdav might be better than FTP
Certainly it was faster and more reliable when I was playing with Duplicati as a backup method to a Synology
 

djb

Explorer
Joined
Nov 15, 2019
Messages
76
yes, webdav is also an option, as syncthing also. it can be usefull over http.
But since we talking about local backups, anything can do the sync is ok.
the truth is i had issues with syncthing [Truenas to Synology].
WebDav and FTP was the 2 options straight forward without strange issues.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
Or you could use active backup on the Synology to backup the SMB Shares
 

JmarcSyd

Dabbler
Joined
Oct 28, 2022
Messages
15
For anyone who stumbles upon this thread after a search, the answer is right here and I have successfully got this going between my TrueNAS Scale and Synology DSM 7.0. https://blog.filegarden.net/2021/02/24/backup-truenas-to-synology-via-rsync/
Thanks! It works BUT there is a small mistake in the blog that just drove me crazy.

The line:
"AuthorizedKeyfile .ssh/authorized_key" in /etc/ssh/sshd_config should be:
"Authorizedkeysfile .ssh/authorized_keys" (note keys instead of key).

I has simply copied the line from the blog and when I restarted SSH, I couldn't SSH back in anymore. I had to enable telnet to be able to go back in and fix it. But it took me ages to figure out what the problem was. So instead of pasting the line from the blog, just remove the comment from the existing line in sshd_config as it's already there (silly me).

Apart from that yes it works well!
 

Attachments

  • rsync.jpg
    rsync.jpg
    19.8 KB · Views: 174

JmarcSyd

Dabbler
Joined
Oct 28, 2022
Messages
15
Thanks! It works BUT there is a small mistake in the blog that just drove me crazy.

The line:
"AuthorizedKeyfile .ssh/authorized_key" in /etc/ssh/sshd_config should be:
"Authorizedkeysfile .ssh/authorized_keys" (note keys instead of key).

I has simply copied the line from the blog and when I restarted SSH, I couldn't SSH back in anymore. I had to enable telnet to be able to go back in and fix it. But it took me ages to figure out what the problem was. So instead of pasting the line from the blog, just remove the comment from the existing line in sshd_config as it's already there (silly me).

Apart from that yes it works well!
Update: it works and I am able to run RSYNC jobs from my TrueNAS to my DS212j but I think SSH is really taxing on the old DS212j CPU as it maxes to 100% while transferring large files and the transfer rate is only 60-70 Mbps, much slower than over SMB. It's okay for overnight incremental backups though.
 

Attachments

  • rsyncspeed.jpg
    rsyncspeed.jpg
    39.1 KB · Views: 144
Top