<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>synology | /var/logs/paulooi.log</title>
	<atom:link href="https://logs.paulooi.com/tag/synology/feed" rel="self" type="application/rss+xml" />
	<link>https://logs.paulooi.com</link>
	<description>Systems Admin, Web Development and etc</description>
	<lastBuildDate>Tue, 21 Jul 2015 04:33:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>How to Rsync from Remote Server to Synology</title>
		<link>https://logs.paulooi.com/how-to-rsync-from-remote-server-to-synology.php</link>
					<comments>https://logs.paulooi.com/how-to-rsync-from-remote-server-to-synology.php#comments</comments>
		
		<dc:creator><![CDATA[Paul Ooi]]></dc:creator>
		<pubDate>Tue, 21 Jul 2015 04:33:33 +0000</pubDate>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Systems]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[synology]]></category>
		<category><![CDATA[sysadmin]]></category>
		<guid isPermaLink="false">http://systems.takizo.com/?p=1757</guid>

					<description><![CDATA[<p>I hava a synology at home, mainly use to store important files, and realize beside have a backup of my server files on dropbox, may be it can have another copy in Synology as well. I explored the possibility of...</p>
The post <a href="https://logs.paulooi.com/how-to-rsync-from-remote-server-to-synology.php">How to Rsync from Remote Server to Synology</a> first appeared on <a href="https://logs.paulooi.com">/var/logs/paulooi.log</a>.]]></description>
										<content:encoded><![CDATA[<p>I hava a synology at home, mainly use to store important files, and realize beside have a backup of my server files on dropbox, may be it can have another copy in Synology as well. I explored the possibility of rsync the backup either on dropbox or server into synology, and&#8230; it works!</p>
<p>Here is what you need to prepare before proceed with the backup. </p>
<p>1. Create a directory for backup. i.e folder name of ServerBackup. Go to &#8220;Control Panel&#8221; -> &#8220;Shared Folder&#8221;. </p>
<p>2. Enable SSH on Synology. Go to &#8220;Control Panel&#8221; -> &#8220;Terminal &#038; SNMP&#8221; -> &#8220;Enable SSH Service&#8221;. If you option to change the SSH port or not <img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><a href="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-enablessh.png"><img decoding="async" src="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-enablessh-300x140.png" alt="synology-backup-enablessh" width="300" height="140" class="aligncenter size-medium wp-image-1758" srcset="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-enablessh-300x140.png 300w, https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-enablessh.png 594w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>3. Try to ssh into Synology with username &#8220;root&#8221;. The root password is the same with &#8220;admin&#8221;. </p>
<p>If are you done, let&#8217;s do it. </p>
<p><strong>Generate SSH Key</strong></p>
<p>You wouldn&#8217;t want to key in password whenever want to access to the server to grab the file. Generate a &#8220;custom&#8221; ssh key which will be used for synology. Remember, please do not set the password. Give you ssh file a &#8220;special name&#8221;, DO NOT use the default. I.e we used synobackup, there are 2 files will be generate </p>
<p>1. synobackup &#8211; This is the private key files<br />
2. synobackup.pub &#8211; This is the public key which will be placed on the remote server. </p>
<p><a href="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-sshkey.png"><img fetchpriority="high" decoding="async" src="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-sshkey-300x231.png" alt="synology-backup-sshkey" width="300" height="231" class="aligncenter size-medium wp-image-1759" srcset="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-sshkey-300x231.png 300w, https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-sshkey.png 537w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Next, we will copy this 2 files into Synology folder ServerBackup. We create a folder name &#8220;scripts&#8221;, and the file will be placed in synology</p>
<p>1. /Volume/ServerBackup/scripts/synobackup<br />
2. /Volume/ServerBackup/scripts/synobackup.pub</p>
<p>We will copy the key on synobackup.pub into remote server&#8217;s ssh directory &#8220;.ssh/authorized_keys&#8221; for the user&#8217;s home directory where you will login with the username later. i.e &#8220;/home/takizo/.ssh/authorized_keys&#8221;</p>
<p><a href="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-homeauthorizedkey.png"><img decoding="async" src="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-homeauthorizedkey-300x101.png" alt="synology-backup-homeauthorizedkey" width="300" height="101" class="aligncenter size-medium wp-image-1760" srcset="https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-homeauthorizedkey-300x101.png 300w, https://logs.paulooi.com/wp-content/uploads/2015/07/synology-backup-homeauthorizedkey.png 453w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Ok.. we are done with ssh thingy. Let&#8217;s write some script. </p>
<p><strong>Simple Scripting</strong></p>
<p>Next, we will do some scripting as below. </p>
<pre>
#!/bin/ash

#This is the private key
PRIVKEY="/volume/ServerBackup/scripts/snology"

#This is the folder you would like to backup from
HOSTFOLDER=/backup/*

#This is the folder you would like to backup to Synology
DESTFOLDER="/volume/ServerBackup/database/server-godzilla/"

#We will be using rsync in synology, this will do the rync! 
/usr/syno/bin/rsync -avz -e "ssh -p7777 -i $PRIVKEY" takizo@godzilla.takizo.com:$HOSTFOLDER $DESTFOLDER
</pre>
<p>Save the script above into your Synology backup folder which created earlier &#8220;/volume/ServerBackup/scripts/database.backup.sh&#8221; </p>
<p>Please take note that the remote folder is define by yourself. We are done with the script, it&#8217;s time to Execute it! </p>
<p><strong>Configure the Backup Script</strong></p>
<p>Due to it&#8217;s the first time access to the remote server, you need to manually run the script in shell to accept the SSH session. We are almost there. </p>
<p>SSH to Synology server </p>
<pre>
ssh -p2222 root@your_synology_ip
mydisk> cd /volume/ServerBackup/scripts
mydisk> ./database.backup.sh
The authenticity of host '[godzilla.takizo.com]:2222 ([123.456.123.111]:2222)' can't be established.
ECDSA key fingerprint is f7:9b:d6:92:7b:33.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[godzilla.takizo.com]:2222,[123.456.123.111]:2222' (ECDSA) to the list of known hosts.
receiving incremental file list
20150721122502.dbbackup.tar.gz

sent 42 bytes  received 18901016 bytes  1021678.81 bytes/sec
total size is 18997573  speedup is 1.01
</pre>
<p>The important part for this action is this line</p>
<pre>
Warning: Permanently added '[godzilla.takizo.com]:2222,[123.456.123.111]:2222' (ECDSA) to the list of known hosts.
</pre>
<p>This will add the host into /root/.ssh/known_hosts, when the script is run next time, it will not prompt the message again.</p>
<p><strong>Setup the Task on Synology</strong></p>
<p>Since the script is working perfectly fine. The last step is add it into Synology&#8217;s Task Schedule. </p>
<p>1. Go to &#8220;Control Panel&#8221; -> &#8220;Task Schedule&#8221;<br />
2. Create &#8220;User defined-script&#8221;<br />
3. Give a meaningful name for your &#8220;Task&#8221;<br />
4. User choose &#8220;root&#8221; or any user you prefer<br />
5. User-defined script: The script you created earlier inside Synology folder, &#8220;/volume/ServerBackup/scripts/database.backup.sh&#8221;<br />
6. Put up a schedule for this, how often it should run and at what time. </p>
<p>After the schedule has been created, try run it again and check is the files transfer into your Synology folder (if you don&#8217;t have new copy of file in the server, delete the files earlier being rsync into synology).</p>
<p>Yep, basically you have another copy of backup on synology! Enjoy backup more stuff from remote server <img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>The post <a href="https://logs.paulooi.com/how-to-rsync-from-remote-server-to-synology.php">How to Rsync from Remote Server to Synology</a> first appeared on <a href="https://logs.paulooi.com">/var/logs/paulooi.log</a>.]]></content:encoded>
					
					<wfw:commentRss>https://logs.paulooi.com/how-to-rsync-from-remote-server-to-synology.php/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
