Help for Rsync server menu
Rsync can be also used as a daemon. In this configuration, copying files with
the rsync utility in client server mode uses the rsync utility on the initiating
side and an rsyncd on the server side. The amount of data transferred between
client and server is optimized for file copy across a slow (internet) connection
and also when resources are limited (ie low speed CPU).
Note: You can find some useful guides how to use rsync with advanced options on the plugout board (Rsync: Guides & Tutorials)
I - Rsync Server menu
This new menu allows you to set the rsync server configuration :
Change the port listened by the server
Of course, you can't select a port used by another server.
Note : port '5873' is reserved for using a rsync daemon via a remote shell connection
Exclude some files by specifying exclude patterns.
On the client side, the user
can select also additional rules to exclude some other files but in a normal
use it can't overwrite the server's exclude rules.
Patterns
must be entered in the text box, separated by ":"
Note : spaces in end and at the beginning of pattern are removed except
if the pattern is framed by simple quote (').
Pattern :
*.o : would exclude all names matching
/foo : would exclude a file (or directory) named foo in the source-root
folder
foo/ : would exclude any folder named foo
/foo/*/bar : would exclude any file named bar which is at two levels below
a folder named foo in the source-root folder
/foo/** /bar : would exclude any file named bar two or more levels below a
folder named foo in the source-root source
Custom a welcome message
Can be useful to identify the server on the client
side and display some explanations for the client.
Change the password of the rsync account
For using the feature 'rsync server via a remote shell connection', a non-root account is available : 'rsyncd'.
By default, its password is 'giveit2rsyncd'.
(see the chapter "Use Rsync server via a remote shell connection")
Select which shares, usually called 'module', will be available via the rsync server.
In the rsync server configuration, all modules require an authentication. Rsync uses the user accounts set for the samba server and the table lists all available accounts for each module. However rsync manages pretty differently the related permissions of these account. Indeed, you can not set different permissions for each selected accounts for a module.
You can define only one permission type and the selected accounts will have the access attribute set in the column 'readonly'.
As with the samba server behavior, the modules 'public' have always a full access.
If the public module is protected, you can use only its related account (which has the same name).
Monitor 'who' uses the server and what resources
The tab 'Rsync server Monitoring' lists all active connections and allows you to stop them if needed
Note: This tab doesn't list accesses via a remote shell connection
Read the Rsync server log
The tab 'Rsync log file' displays the current log and allows you also to erase or export the file.
Note : If users have used the feature 'rsync server via a remote shell connection', the relevant log is also displayed: its content is prefixed by '[ssh]'
Temporarily change the status of the server (stop or start)
Note: if you have never saved a configuration in the NAS database, these commands are disabled
Warning : as the rsync protocol is not safe
(transfer flux without encryption) you should use it only on your LAN. By default, the connections from remote hosts are disallowed in the configuration.
If you
want to use it across an Internet connection, you must use it via a remote shell
connection (see the chapter "Use Rsync server via a remote shell connection").
II - How use the rsync server
On the client side, you must use rsync commands from a shell terminal. For linux or MAC, rsync is usually available. From operating windows systems, you can install, for example, cygwin which allows to implement a fake shell and in our case also rsync (see the chapter "Install cwrsync and use rsync with windows").
On the client side open a shell terminal (or Putty if the client is another NAS, or cygwin Terminal for windows OS) and give the following commands for :
List the available modules:
login is any name, nasname is the ip or the host name where the rsync server is running. Note the double ":" and you get this output :
List the content of a module or a subfolder:
or with a subfolder
login is only an authorized authentication. In this case, the server asks you
to give the related password (see the chapter 'How use a
password file' for giving directly the password).
modulename is the sharename of an available share
and the output is :
Synchronize a local folder with your NAS:
To copy a local folder to the NAS
To copy a NAS content to your local folder:
[backup options]
common rsync options used :
-a : usually used.
Note: don't use this option if client's OS is windows and replace it
by -rlt (never use the options p, o and g)
-z : to compress file before sending. I advice you not to use it if you backup
from the NAS (transfer speed is lower in this case : not enough resource to do
that)
--delete : use it to get an perfect copy between source and
destination. In destination, all file will be deleted if it doesn't
exist in source folder
--stats : to get some transfer statistic
-v : to get a verbose output
--port=PORT use it only if the server doesn't listen the default port (873)
and PORT is the value of your custom port
Of course, you can use these lines with cron or in any shell
file.
If you want to save
the output (stats) make a redirection : add at the end of the command line : > 'pathto..yourlogfile'
From an OS windows, see the chapter "Install cwrsync and use rsync with windows"
You can add the option : --password-file='pathto..yourpassfile' to give directly the password (useful with a shell script or cron). This file must contains only the related password of the login that you want to use to access to the module (not space or break line).
Before using it, rsync checks if the file is readable only by the account with which
it runs. Otherwise you get this error message:
So on a linux system, you must check if password file owner is the same than this one used to run the rsync command line and its permissions must be 600.
Note : if you make a copy from another NAS with fvdw-sl firmware, root must be
the owner of the password file and have the permissions 600 (or rw------- )
For OS windows, see the chapter "Install cwrsync and use rsync with windows"
IV - Use Rsync server via a remote shell connection
Using rsync daemon over a remote shell connection is
relatively simple : you use the same command line and you must add only one
option : 'e' to set which ssh client to be used.
When you used this features, it's not the current rsync daemon but
a dedicated daemon started by the ssh client. So you can used this feature even
if the rsync server is not running. It will used the parameters saved in the nas
database. Of course, if you never saved a configuration, you can't use it !
The options to declare with the ssh client are depending the ssh server
configuration of your NAS (see the chapter SSH Access help page)
:
Just add in the rsync command
line (with the double quotes):
I assumed that ssh is the ssh client on the remote OS: with linux/unix
system, it is installed with the package openSSH.
if the client OS is windows see the chapter "Install cwrsync and use rsync with windows".
note : if you use a custom port for the ssh server, you must add the option '-p yourport' and for example if the ssh server port is 222, you will add in the
rsync command line:
So if you give for example the rsync command :
You will have to enter first the password of the account rsyncd to open the
shell connection and then enter the password of the authentication 'authuser' to get access to 'myModule'.
Of course, you still can use the option '--password-file' to give directly
this last password.
In this case you won't need to enter the password of the account rsyncd but you
must have an available rsa key from the rsync client side.
Before using it, you must import it in the SSH Access menu (authorized Public
key) : see the chapter SSH Access help page
In this case the way to use the option '-e' is :
Of course, as for the previous case, if you use a custom port for the ssh server, you must add
also '-p yourport'.
Note : if you use this feature between two NAS with our firmware, for using option '-e':
So the rsync command lines are for example :
V - Install cwrsync and use rsync with windows
After selecting these additional packages, the install program will propose you to add also some dependencies packages (you must accept them!)
Note: you can also add in the PATH environment, the path : c:\cygwin\bin to get a direct access to the shell commands (rsync, nano,...) in a DOS window.
To use easily rsync, open a cygwin Terminal and you get a similar Linux environment. You can use this terminal as Putty and basic shell commands are also available.
For managing local path, I advice you to forget the windows syntax and always use linux syntax (use '/' instead of '\')
To access of your local disks, you must always begin the path by /cygdrive. So to access to a folder of the disk c:, the path will be : '/cygdrive/c/Documents and Settings' . Note : the path string is not sensitive case and use simple quote if the path contains space chars.
Important : You must always use this syntax for the password file path otherwise you will get the error message about read permissions
You can also use rsync in a batch file :
Create a txt file (with notepad, or notepad++,...) and save it with the
extension bat and copy these lines :
These lines copy a folder from the NAS to a local folder and delete all file in the local folder if it doesn't exist in the NAS folder (option --delete). Swap the order between '/cygdrive/pathto..localfolder' and login@nasname::module/pathto..folder to copy from the client side to your NAS
Note 1: if in the used path you have not ASCII characters, the bat file must be encoded in 'OEM 850' or use directly the very old console 'edit.com' ;-)
Note 2: if you redirect the rsync output in a file you must use Windows syntax (ie: > "c:\Documents and Settings\username\My Documents\rsync.log"). Use also double quote in this case