Using RSync to back files from Windows to Freenas with SSH

Joined
Jul 17, 2014
Messages
9
Thanks
0
#1
I personally had trouble trying to back my files from my windows machine to my freenas server. I never used RSync and documentation about doing this was all over the place. I decided to share this so that I may spare the same troubles I had to other people. I did this months ago so I may actually forget a thing or two, I'll edit if this come to my attention.

Using FreeNAS 9.2.1.7 RELEASE-x64
For Windows we will be using DeltaCopy which you can find online.
We will log with a SSH key so do configure the key for your Freenas account. DeltaCopy doesn't support encrypted keys.

Log into the GUI of your freenas machine and go to Services and start Rsync.
You may also want to create the directories that will receive the files from your windows machine because DeltaCopy will complain that the path doesn't exist (it can't create new directories by itself).

Now, on your Windows machine start the DeltaCopy CLIENT, you only need the client.

On the left panel click "Add New Profile" give it a name, write the IP of your Freenas server for Virtual Directory just write the name of the directory you just created on your server.

You can add a file/folder. Just make sure that the root directory already exist on your server.
ie: E:\User\demon\Documents\school\stuff
A folder named "Documents" need to be created on the server for the sync to work.

Under Options check "Connect via SSH".
under Additional Parameters write:

Code:
-e "./ssh -l User_Name -i id_rsa"

Where User_Name is the user name of the account that you will perform the rsync task on.
Where id_rsa is the name of your SSH key. I have copied both my public and private key in the same folder as the DeltaCopy executable.

If you want to sync a folder but exclude a few files you will have to do that manually by adding the "--exclude=" parameter like this:
Code:
-e "./ssh -l user_name -i id_rsa" --exclude="bin/" --exclude="obj/" --exclude="ipch/"  --exclude="Debug/"


Before you can perform a sync you need to add the freenas into your known host. Unfortunately, DeltaCopy doesn't provide a GUI or even a message informing you of that.

Start the command prompt and go to the folder containing the executable. Execute DeltaCopy with the additional parameters that you just set with the client. You should have a message to add your server to the known host, do that.

Back to the Client, right click on your profile and click run.

Voila!

You may notice that your files or path containing Unicode is just getting corrupted. This is because the version of Cygwin DLLs shipped with DeltaCopy are not compatible with UNICODE file names. You need to locate the proper DLL and replace it from the DeltaCopy installation folder. This is where my memory start to fade, but I think I got mine from here.
 
Last edited:
Joined
Jan 3, 2014
Messages
36
Thanks
0
#2
Hi,

I have managed to get Rsync on FreeNAS to work, both Pull and Push directions, with DeltaCopy (server) on my PC. But have not a clear picture of setting up Rsync over SSH on FreeNAS. Having stumbled over your post, I understand I need DeltaCopy Client running on my PC to push data to FreeNAS server over SSH.

And I am wondering if you can be so kind to help out.

- With ssh keys, did you first create the keys inside FreeNAS, i.e. running ssh-keygen using FreeNAS shell; then afterwards you exported the keys to the PC folder where Delta executable programs reside?

If you had created them from Windows machine, how did you copy the id_rsa.pub key to the root read folder, which is only file system in FreeNAS? I could not copy to it.

Many thanks in advance.
Cheers
 
Joined
Jul 17, 2014
Messages
9
Thanks
0
#3
I'm glad that you are asking me that.

I created the key on my Windows machine with cygwin. I believe the command I ran was:


Code:
ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
(Press enter here)

If it ask for a password to encrypt it, don't enter one, just press enter as I already said in the guide above.
Locate the file you just created (under the cygwin installation folder /home/Username/.ssh)
You should find id_rsa and id_rsa.pub.
Copy the content of the id_rsa.pub into a new file called "authorized_keys" no extensions.

On Freenas webGui, go to service and make sure SSH is active and that it accept Password authentication.

Back on Windows (cygwin) you need to establish an ssh connection.
Code:
ssh MyUserName@FreenasBoxIP
<Enter password>


Once connected on your home directory you will have to make a .ssh directory if one doesn't exist already and copy the key you just created to it.

Code:
mkdir ~/.ssh

Disconnect from the SSH session, but still in cygwin:

Code:
scp authorized_keys MyUserName@FreenasBoxIP:~/.ssh/

Which copy the authorized_keys file to your freenas under the proper folder. You might need to modify this command depending on where your authorized_keys is. I think it should work if it's located in your current folder.

Reconnect to the Freenas with SSH and your password, once again.

Code:
cd ~/.ssh/
chmod 600 authorized_keys


To make it readable and writable by the owner.

Terminate the connection. Back to the Freenas GUI, go to service, configure SSH.
Uncheck the option for Password authentification.

Now try to connect with cygwin with SSH without entering the password.

The id_rsa and id_rsa.pub files that we left on cygwin are the one that I copied to the DeltaCopy folder as described above.

Source
 
Joined
Jan 3, 2014
Messages
36
Thanks
0
#4
Thank you kindly for your detailed reply. I did not expect that quick a ... volunteer's service. :).

Let me work on it and reply later.
Cheers
 
Joined
Jan 3, 2014
Messages
36
Thanks
0
#5
Hi,

I followed the steps your post. But I have not been able to run the very last command. Kinda Murphy's law:

chmod 600 authorized_keys


I spent the last several hours trying including redoing it from the start. But no matter what I tried, FreeNAS always returns message along the line:

Operation not permitted.

or

Sorry, user name is not allowed to execute '/bin/chmod 600 authorized_keys' as root on ...
if I added sudo in front of chmod...

Wondering if you came across this issue and may be able to point out something.

Many thanks.
 
Joined
Jul 17, 2014
Messages
9
Thanks
0
#6
Completely forgot, I actually had the same issue and talked about it on this thread.
If Unix file system is used maybe you only need to enable "su" for your account. On the webGui, Go to Account->Users. Modify your user account and in the options (maybe advanced options) you should find a checkbox for enabling "su". Maybe not. Otherwise:

I "fixed" it by
rebuil[ding] the LDAP Cache (under Settings -> Advanced). Then recreat[ing] my user and dataset.
I had a particuliar problem in my case and I still don't understand why it fixed it so it might not do anything in your case.

Try
using setfacl instead of chmod.
, but this is where I can no longer help, I don't know the command.

Rogla on the thread I linked above fixed it by doing the following:

Simply use command 'getfacl file' to list the ACL's.
To delete the ACL, copy the ACL string (everyone and group) and paste it into command 'setfacl -x ACL file'
 
Last edited:
Joined
Jan 3, 2014
Messages
36
Thanks
0
#7
Let me work through it. And I will reply.

I really appreciate your help to a fellowman and also a noob as far as Unix/Linux goes.

I learn a lot since I settled on Rsync to enable backup from Windows to FreeNAS. And it has nothing to do with Andrew Tridgell, creator of Rsync, being an Australian.

And the more I learn about it, the less I realize what I know, as the favorite saying goes. :)

Cheers
 
Joined
Jan 3, 2014
Messages
36
Thanks
0
#8
Close but no cigar.

I think I am close to solving the SSH issue. Hopefully today, after spending another whole day yesterday. Being out of work, so I have time.

Now I know why a $30m IT project could turn into a $100m one and disowned by participants. It happened where I once worked. I recommended against it at the start but was overrode. :)
 
Joined
Jan 3, 2014
Messages
36
Thanks
0
#9
Hi d_d,

I got a feeling that I am so close, yet so far.

At this moment, I am about to give up on the idea of modifying the security aspect of mySSH.pub key inside my ~ directory. Interestingly, I got it working at CLI but not via DeltaCopy. That was two nights ago. But it's no longer works.

I may have to run Rsync (without SSH) using established VPN via my MikroTik router in the end. You see, I want to use a relative's NAS (or FreeNAS) as remote backup of data on my FreeNAS, and vice versa. In this way, I have no need for a third party, pay money for its service and compromised security. That was my ultimate plan.

Anyway, learning to use Rsync with SSH from having very little prior knowledge of Linux/Unix is like wanting to build a cubby house, up in the tree, for my kids...

It's not as simple as fashioning many pieces of timber together with nails. I gain an understanding of suitability of materials, required measurements such as lengths, thickness and so forth and then the logistics of putting them together up in the tree... in such a way that the kids enjoy it with safety. So to speak.

While I have yet to succeed with Rsync over SSH at this stage, I learn much more about Linux/Unix than before Rsync. So it's not wasted. I regard as a building block...

Really appreciated your help and for being generous with your time.

Cheers.
 
Last edited:
Top