Rsync SSH from NAS to Ubuntu - Automated

Status
Not open for further replies.

Medic303

Cadet
Joined
Mar 9, 2017
Messages
2
There are a lot of articles showing how to go from linux to FreeNAS or Windows to FreeNAS but I haven't been able to find any guide that can help me Rsync through SSH from FreeNAS to a Linux.

I'm trying to backup the FreeNAS system at my office to an offsite Ubuntu Server 14.04. If I need to, I supposed I can set up a VM with FreeNAS on the server and go from NAS to NAS but if you have a guide or can point me in the right direction to help me, I'd greatly appreciate it.

I set up a user on the FreeNAS called SysBackup. I created the same user on my offsite server called SysBackup. I can sucessfully Rsync over SSH if I log in manually but what I would like to do is set a task that automates it for me without having to log in every time or a task that will log in for me when the task runs.

Many thanks!!
 

Osiris

Contributor
Joined
Aug 15, 2013
Messages
148
I've got the setup the other way around: I rsync a file from a debian/raspbian to a FreeNAS jail.
Perhaps some of this might assist you.

I've got an rsync running in a FreeNAS jail towards a raspbian (which would be the same as an ubuntu/debian server I guess)
Daemons on both systems. I use crontab to call a script that fetches certain files from the raspbian.

In the jail, in /etc/rc.conf I've got
Code:
rsyncd_enable="YES"


Create a password file on both systems and make sure to test the connection.
On the FreeBSD jail, /usr/local/etc/rsync/rsyncd.passfile contains
Code:
mypassword

On the raspbian, /etc/rsyncd.secrets contains
Code:
rsyncuser:mypassword

On the raspbian, /etc/rsyncd.conf contains
Code:
max connections = 4
timeout = 300
[nameofshare]
  comment = blabla
  path = /mnt/nameofshare
  read only = yes
  list = yes
  uid = root
  gid = root
  auth users = rsyncuser
  secrets file = /etc/rsyncd.secrets


In the freenas jail I can /usr/local/bin/rsync -v --password-file=/usr/local/etc/rsync/rsyncd.passfile rsync://rsyncuser@target-system-ip/nameofshare/somefile.txt /localfolder/

So I've added this to a script and I'm running this script from crontab.
Code:
crontab -e

*/5 * * * * /bin/sh /mnt/script/get_stuff.sh

Code:
#!/bin/sh
/usr/local/bin/rsync -v --password-file=/usr/local/etc/rsync/rsyncd.passfile rsync://rsyncuser@target-system-ip/nameofshare/somefile.txt /localfolder/ >> /var/log/somefile.log 2>> /var/log/somefile.log
 
Last edited:
Status
Not open for further replies.
Top