Backup Linux desktop data using rsync: Difference between revisions

From wiki
Jump to navigation Jump to search
imported>Notessensei
(Initial creation of page)
 
imported>Johayek
mNo edit summary
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__TOC__
__TOC__


Linux servers and desktops can be backed up using the rsync protocol which is a core component of every Linux system. For and introduction check the [[wikipedia:Rsync|Rsync article]] on [[wikipedia:Main|Wikipedia]]. [http://www.samba.org/ftp/rsync/rsync.html The official documentation] can be found on the Samba website. Rsync is an efficient protocol only sending changes. Rsync does not encrypt transmissions, so a remote shell like SSH or RSH should be used in public network. There are a number of [http://everythinglinux.org/rsync/|Rsync Tutorials] available ([http://www.mikerubel.org/computers/rsync_snapshots/ here], [http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/ here] or [http://www.google.com/search?q=rsync+tutorial here]). This page describes the steps to setup rsync backup from a Linux machine to a Synology DiskStation.
Linux servers and desktops can be backed up using the rsync protocol which is a core component of every Linux system. For and introduction check the [[wikipedia:rsync|rsync article]] on [[wikipedia:Main|Wikipedia]]. [http://www.samba.org/ftp/rsync/rsync.html The official documentation] can be found on the Samba website. Rsync is an efficient protocol only sending changes. rsync does not encrypt transmissions, so a remote shell like SSH or RSH should be used in public network. There are a number of [http://everythinglinux.org/rsync/|Rsync Tutorials] available ([http://www.mikerubel.org/computers/rsync_snapshots/ here], [http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/ here] or [http://www.google.com/search?q=rsync+tutorial here]). This page describes the steps to setup rsync backup from a Linux machine to a Synology DiskStation.


<b>ToDo</b>:Currently the article is a stub which needs extension.
<b>ToDo</b>:Currently the article is a stub which needs extension.


==What to choose: native Rsync or Rsync via SSH/RSH?==
==What to choose: native rsync or rsync via SSH/RSH?==
Depending on your needs these are the decision criteria:
Depending on your needs these are the decision criteria:
* Speed
* Speed
Line 12: Line 12:
<b>ToDo</b>: Elaborate
<b>ToDo</b>: Elaborate


==Setting up Synology for Rsync==
==Setting up Synology for rsync==
To enable backup via Rsync the Rsync deamon on the Synology needs to be activated and Sync targets need to be defined.
To enable backup via rsync the rsync deamon on the Synology needs to be activated and Sync targets need to be defined.


<b>Activating Rsync</b><br />
<b>Activating rsync</b><br />
Start your Synology DiskStation Manager. Go to Backup - Network Backup Service and check the box "Enable network backup service". Click OK - that's all.
Start your Synology DiskStation Manager. Go to Backup - Network Backup Service and check the box "Enable network backup service". Click OK - that's all.


<b>Creating Rsync targets</b><br />
<b>Creating rsync targets</b><br />
You need to edit the file <b>/etc/rsyncd.conf</b>. You can do that either by opening an SSH session into the DiskStation or using the [http://www.mertymade.com/syno/#cfe Config File Editor] Third party application. To use it you need to first edit the config File editor config itself and add the line /etc/rsyncd.conf (It seems you have to create the file before the Config File Editor will pick it up). You also might need a file /etc/rsyncd.secrets for users to use rsync connections
You need to edit the file <b>/etc/rsyncd.conf</b>. You can do that either by opening an SSH session into the DiskStation or using the [http://www.mertymade.com/syno/#cfe Config File Editor] Third party application. To use it you need to first edit the config File editor config itself and add the line /etc/rsyncd.conf (It seems you have to create the file before the Config File Editor will pick it up). You also might need a file /etc/rsyncd.secrets for users to use rsync connections


Line 24: Line 24:
<b>ToDo</b>: Add file content here and add explanations to the various entries
<b>ToDo</b>: Add file content here and add explanations to the various entries


==Setting up Synology for Rsync via SSH/RSH==
==Setting up Synology for rsync via SSH/RSH==
<b>ToDo</b>: Elaborate
When using ssh no rsync deamon is used on the DiskStation. However you need to have a valid public / private key pair, so the DiskStation can recognize the Linux machine. Follow the following steps ([http://troy.jdmz.net/rsync/index.html adopted from here])
 
<b>Generate they key pair</b>
 
<code>
mkdir ~/.sshkeys<br />
cd ~/.sshkeys<br />
ssh-keygen -t dsa -b 1024 -f ~/.sshkeys/diskstation-rsync-key
</code>
 
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase): [press enter here]<br />
Enter same passphrase again: [press enter here]<br />
Your identification has been saved in ... diskstation-rsync-key. <br />
Your public key has been saved in  ... diskstation-rsync-key. <br />
( where  ... stands for your directory )<br />
<code>
chmod 600 diskstation-rsync-key
</code>
 
If you want to connect without using a passphrase, you must not enter any passphrase when ask (just it the "Enter" key)
 
<b>Transfer the keys</b><br />
First, you will have to enable the "homes" directory" through your Synology web interface. (all "homes" are created under directory ''/volume1/homes/'')
Use your file manager (e.g. Nautilus) to navigate to <code>[YourUserName]@smb://diskstation/home/</code><br />
Create a directory <code>.ssh</code> and copy diskstation-rsync-key.pub there.<br />
Now open a SSH connection to the diskstation to continue:<br />
<code>
ssh user@diskstation [Enter password here]<br />
cd /volume1/homes/[YourUserName]/.ssh<br />
ls -l
</code>
 
If there is already a "authorized_keys" file you skip the first line of the following code:
 
<code>
touch authorized_keys<br />
cat diskstation-rsync-key.pub >> authorized_keys<br />
rm diskstation-rsync-key.pub<br />
chmod 600 authorized_keys<br />
</code>
You can restrict the use of this key for specific commands or IP addresses ([http://troy.jdmz.net/rsync/index.html see here]).<br />
Exit from the SSH session. Now you are ready to test the keys with the following command:<br />
<code>
ssh -i ~/.sshkeys/diskstation-rsync-key [YourUserName]@diskstation
</code><br />
If you get a ssh session without a password prompt the ssh connection using your new keys works.<br />
 
<b>Sample backup command</b><br />
<code>
rsync --recursive --copy-links --times --verbose  --progress -e "ssh -i ~/.sshkeys/diskstation-rsync-key" \<br />
/home/[localusername] [YourUserName]@diskstation:/volume1/homes/[YourUserName]/backup
</code><br />
This will:
* Connect through SSH to your Synology, using the set of key you previously created
* Copy recursively all from /home/[localusername] to your Synology, within /volume1/homes/[YourUserName]/backup directory (no need to create "backup")
* Copy referents to symbolic links
* Preserve ties from your files
* Show you the progress from copy (not useful if you are running it with a cron)
<b>TODO:</b> Explain a little more


==Backing up your Linux workstation using RSync==
==Backing up your Linux workstation using rsync==
<b>ToDo</b>: Elaborate
<b>ToDo</b>: Elaborate


==GUI Tools using RSync for backup==
==GUI Tools using rsync for backup==
[[Wikipedia:FlyBack|Flyback]] rSync tool modeled after TimeMachine ([http://code.google.com/p/flyback/ Flyback on Google code])
[[Wikipedia:FlyBack|Flyback]] rSync tool modeled after TimeMachine ([http://code.google.com/p/flyback/ Flyback on Google code])
<br />[http://qtdtools.doering-thomas.de/page.php?seite=0&sub=0&lang=en QTDSync]
<br />[http://qtdtools.doering-thomas.de/page.php?seite=0&sub=0&lang=en QTDSync]
<br />[http://gadmintools.flippedweb.com/index.php?option=com_content&task=view&id=51&Itemid=38 GAdmin tool for RSync]
<br />[http://gadmintools.flippedweb.com/index.php?option=com_content&task=view&id=51&Itemid=38 GAdmin tool for rsync]
<br /><b>ToDo</b>: complete the list of Linux GUI applications using Rsync.
<br />[http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp DeltaCopy] (Windows rsync GUI)
<br /><b>ToDo</b>: complete the list of Linux GUI applications using rsync.
 
==Synchronize Sabnzbd and Synology==
If you have a server somewhere with Sabnzbd on it and you want to move what you downloaded from the server to your Synology, please have a look to [http://blog.metabaron.net/index.php?post/2011/04/14/Sabnzbd-and-Synology|this blog entry]
 
[[Category:SynologyWiki]]
[[Category:ToBeExported]]

Latest revision as of 17:36, 31 January 2015

Linux servers and desktops can be backed up using the rsync protocol which is a core component of every Linux system. For and introduction check the rsync article on Wikipedia. The official documentation can be found on the Samba website. Rsync is an efficient protocol only sending changes. rsync does not encrypt transmissions, so a remote shell like SSH or RSH should be used in public network. There are a number of Tutorials available (here, here or here). This page describes the steps to setup rsync backup from a Linux machine to a Synology DiskStation.

ToDo:Currently the article is a stub which needs extension.

What to choose: native rsync or rsync via SSH/RSH?[edit]

Depending on your needs these are the decision criteria:

  • Speed
  • Security
  • Access control

ToDo: Elaborate

Setting up Synology for rsync[edit]

To enable backup via rsync the rsync deamon on the Synology needs to be activated and Sync targets need to be defined.

Activating rsync
Start your Synology DiskStation Manager. Go to Backup - Network Backup Service and check the box "Enable network backup service". Click OK - that's all.

Creating rsync targets
You need to edit the file /etc/rsyncd.conf. You can do that either by opening an SSH session into the DiskStation or using the Config File Editor Third party application. To use it you need to first edit the config File editor config itself and add the line /etc/rsyncd.conf (It seems you have to create the file before the Config File Editor will pick it up). You also might need a file /etc/rsyncd.secrets for users to use rsync connections

Sample file content (see also the full documentation)
ToDo: Add file content here and add explanations to the various entries

Setting up Synology for rsync via SSH/RSH[edit]

When using ssh no rsync deamon is used on the DiskStation. However you need to have a valid public / private key pair, so the DiskStation can recognize the Linux machine. Follow the following steps (adopted from here)

Generate they key pair

mkdir ~/.sshkeys
cd ~/.sshkeys
ssh-keygen -t dsa -b 1024 -f ~/.sshkeys/diskstation-rsync-key

Generating public/private dsa key pair. Enter passphrase (empty for no passphrase): [press enter here]
Enter same passphrase again: [press enter here]
Your identification has been saved in ... diskstation-rsync-key.
Your public key has been saved in ... diskstation-rsync-key.
( where ... stands for your directory )
chmod 600 diskstation-rsync-key

If you want to connect without using a passphrase, you must not enter any passphrase when ask (just it the "Enter" key)

Transfer the keys
First, you will have to enable the "homes" directory" through your Synology web interface. (all "homes" are created under directory /volume1/homes/) Use your file manager (e.g. Nautilus) to navigate to [YourUserName]@smb://diskstation/home/
Create a directory .ssh and copy diskstation-rsync-key.pub there.
Now open a SSH connection to the diskstation to continue:
ssh user@diskstation [Enter password here]
cd /volume1/homes/[YourUserName]/.ssh
ls -l

If there is already a "authorized_keys" file you skip the first line of the following code:

touch authorized_keys
cat diskstation-rsync-key.pub >> authorized_keys
rm diskstation-rsync-key.pub
chmod 600 authorized_keys
You can restrict the use of this key for specific commands or IP addresses (see here).
Exit from the SSH session. Now you are ready to test the keys with the following command:
ssh -i ~/.sshkeys/diskstation-rsync-key [YourUserName]@diskstation
If you get a ssh session without a password prompt the ssh connection using your new keys works.

Sample backup command
rsync --recursive --copy-links --times --verbose --progress -e "ssh -i ~/.sshkeys/diskstation-rsync-key" \
/home/[localusername] [YourUserName]@diskstation:/volume1/homes/[YourUserName]/backup

This will:

  • Connect through SSH to your Synology, using the set of key you previously created
  • Copy recursively all from /home/[localusername] to your Synology, within /volume1/homes/[YourUserName]/backup directory (no need to create "backup")
  • Copy referents to symbolic links
  • Preserve ties from your files
  • Show you the progress from copy (not useful if you are running it with a cron)

TODO: Explain a little more

Backing up your Linux workstation using rsync[edit]

ToDo: Elaborate

GUI Tools using rsync for backup[edit]

Flyback rSync tool modeled after TimeMachine (Flyback on Google code)
QTDSync
GAdmin tool for rsync
DeltaCopy (Windows rsync GUI)
ToDo: complete the list of Linux GUI applications using rsync.

Synchronize Sabnzbd and Synology[edit]

If you have a server somewhere with Sabnzbd on it and you want to move what you downloaded from the server to your Synology, please have a look to blog entry