<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>backup-with-rsync &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/backup-with-rsync/</link>
	<description>Feed of posts on WordPress.com tagged "backup-with-rsync"</description>
	<pubDate>Sun, 26 May 2013 08:20:22 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Automatic backup from Ubuntu Server with Rsync ]]></title>
<link>http://rbgeek.wordpress.com/2012/05/22/automatic-backup-from-ubuntu-server-with-rsync/</link>
<pubDate>Tue, 22 May 2012 12:18:43 +0000</pubDate>
<dc:creator>rbgeek</dc:creator>
<guid>http://rbgeek.wordpress.com/2012/05/22/automatic-backup-from-ubuntu-server-with-rsync/</guid>
<description><![CDATA[Scenario: 2 Ubuntu Server: 1 is named as tendo-Srv with an ip address of 192.168.1.190, from which w]]></description>
<content:encoded><![CDATA[<p><a href="http://rbgeek.files.wordpress.com/2012/05/ser1.jpg"><img class="aligncenter size-full wp-image-1022" title="ser" alt="" src="http://rbgeek.files.wordpress.com/2012/05/ser1.jpg?w=583&#038;h=395" width="583" height="395" /></a></p>
<h6>Scenario:</h6>
<p><span style="color:#ff0000;"><strong>2 Ubuntu Server:</strong></span> 1 is named as <span style="color:#ff0000;">tendo-Srv</span> with an ip address of <span style="color:#ff0000;">192.168.1.190</span>, from which we want to take backup and 1 is named as <span style="color:#ff0000;">tendo-backup</span> with an ip address of <span style="color:#ff0000;">192.168.1.177</span>, on which we want to place our backup. But we want all this process automatic, at a defined time/ interval.</p>
<p>Generate the ssh key pair on <span style="color:#ff0000;">tendo-Srv</span>:</p>
<pre><span style="color:#ff0000;">ssh-keygen</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/150.jpg"><img class="aligncenter size-full wp-image-1023" title="1" alt="" src="http://rbgeek.files.wordpress.com/2012/05/150.jpg?w=630&#038;h=372" width="630" height="372" /></a></p>
<p><!--more-->Copy the public key to the <span style="color:#ff0000;">tendo-backup</span>:</p>
<pre><span style="color:#ff0000;">scp ~/.ssh/id_rsa.pub arbab@192.168.1.177:</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/227.jpg"><img class="aligncenter size-full wp-image-1025" title="2" alt="" src="http://rbgeek.files.wordpress.com/2012/05/227.jpg?w=630&#038;h=155" width="630" height="155" /></a></p>
<p>Connect to the <span style="color:#ff0000;">tendo-backup</span>:</p>
<pre><span style="color:#ff0000;">ssh arbab@192.168.1.177</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/322.jpg"><img class="aligncenter size-full wp-image-1027" title="3" alt="" src="http://rbgeek.files.wordpress.com/2012/05/322.jpg?w=630&#038;h=336" width="630" height="336" /></a></p>
<p>Append the public key to authorized_keys:</p>
<pre><span style="color:#ff0000;">cat id_rsa.pub &#62;&#62; ~/.ssh/authorized_keys</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/423.jpg"><img class="aligncenter size-full wp-image-1029" title="4" alt="" src="http://rbgeek.files.wordpress.com/2012/05/423.jpg?w=630&#038;h=107" width="630" height="107" /></a></p>
<p>We got an error saying &#8220;<span style="color:#ff0000;">~/.ssh/authorized_keys: No such file or directory</span>&#8221; it means that there is no .ssh directory for this user (this user has never used ssh before). Simply create an empty .ssh directory with <span style="color:#ff0000;">700</span> permissions:</p>
<pre><span style="color:#ff0000;">mkdir ~/.ssh</span>
<span style="color:#ff0000;">chmod 700 ~/.ssh</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/521.jpg"><img class="aligncenter size-full wp-image-1032" title="5" alt="" src="http://rbgeek.files.wordpress.com/2012/05/521.jpg?w=630&#038;h=94" width="630" height="94" /></a></p>
<p>Now,try to append the public key to <span style="color:#ff0000;">authorized_keys</span> once again:</p>
<pre><span style="color:#ff0000;">cat id_rsa.pub &#62;&#62; ~/.ssh/authorized_keys</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/624.jpg"><img class="aligncenter size-full wp-image-1034" title="6" alt="" src="http://rbgeek.files.wordpress.com/2012/05/624.jpg?w=630&#038;h=68" width="630" height="68" /></a></p>
<p>Remove the uploaded copy of <span style="color:#ff0000;">authorized_keys</span>:</p>
<pre><span style="color:#ff0000;">rm id_rsa.pub</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/719.jpg"><img class="aligncenter size-full wp-image-1036" title="7" alt="" src="http://rbgeek.files.wordpress.com/2012/05/719.jpg?w=630&#038;h=61" width="630" height="61" /></a></p>
<p>Edit the ssh server configuration:</p>
<pre><span style="color:#ff0000;">sudo nano /etc/ssh/sshd_config</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/818.jpg"><img class="aligncenter size-full wp-image-1035" title="8" alt="" src="http://rbgeek.files.wordpress.com/2012/05/818.jpg?w=630&#038;h=57" width="630" height="57" /></a></p>
<p>Make sure that public key authentication is enabled (it should be enabled by default), these entries must be set to <span style="color:#ff0000;">yes</span> also:</p>
<pre><span style="color:#ff0000;">RSAAuthentication yes</span>
<span style="color:#ff0000;">PubkeyAuthentication yes</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/917.jpg"><img class="aligncenter size-full wp-image-1040" title="9" alt="" src="http://rbgeek.files.wordpress.com/2012/05/917.jpg?w=630&#038;h=107" width="630" height="107" /></a></p>
<p>Reload the ssh configuration:</p>
<pre><span style="color:#ff0000;">sudo service ssh reload</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/1015.jpg"><img class="aligncenter size-full wp-image-1043" title="10" alt="" src="http://rbgeek.files.wordpress.com/2012/05/1015.jpg?w=630&#038;h=70" width="630" height="70" /></a></p>
<p>Create a directory,where we want to keep the backup on tendo-backup server and set a permission on it:</p>
<pre><span style="color:#ff0000;">sudo mkdir /backup</span>
<span style="color:#ff0000;">sudo chown arbab:arbab /backup/</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/backup1.jpg"><img class="aligncenter size-full wp-image-1067" title="backup" alt="" src="http://rbgeek.files.wordpress.com/2012/05/backup1.jpg?w=630&#038;h=103" width="630" height="103" /></a></p>
<p>Disconnect from the<span style="color:#ff0000;"> tendo-backup</span>:</p>
<pre><span style="color:#ff0000;">exit</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/1118.jpg"><img class="aligncenter size-full wp-image-1045" title="11" alt="" src="http://rbgeek.files.wordpress.com/2012/05/1118.jpg?w=630&#038;h=97" width="630" height="97" /></a></p>
<p>Try to connect to <span style="color:#ff0000;">tendo-backup</span> server again, and this time, it will not ask for the password <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre><span style="color:#ff0000;">ssh arbab@192.168.1.177</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/1212.jpg"><img class="aligncenter size-full wp-image-1047" title="12" alt="" src="http://rbgeek.files.wordpress.com/2012/05/1212.jpg?w=630&#038;h=316" width="630" height="316" /></a></p>
<p>Create a separate directory and file, where we want to keep the <span style="color:#ff0000;">rsync</span> log on<span style="color:#ff0000;"> tendo-Srv</span> and set the permission on it as well:</p>
<pre><span style="color:#ff0000;">sudo mkdir /rsynclog</span>
<span style="color:#ff0000;">sudo touch /rsynclog/rsynclog.log</span>
<span style="color:#ff0000;">sudo chmod 0777 /rsynclog/rsynclog.log</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/1311.jpg"><img class="aligncenter size-full wp-image-1050" title="13" alt="" src="http://rbgeek.files.wordpress.com/2012/05/1311.jpg?w=630&#038;h=130" width="630" height="130" /></a></p>
<p>Now, copy the files from <span style="color:#ff0000;">tendo-Srv</span> to <span style="color:#ff0000;">tendo-backup</span> with <span style="color:#ff0000;">Rsync</span>:</p>
<pre><span style="color:#ff0000;">rsync -e ssh --progress --partial --delete -avz  --log-file=/rsynclog/rsynclog.log /data/ arbab@192.168.1.177:/backup</span></pre>
<p><span style="color:#ff0000;"><a href="http://rbgeek.files.wordpress.com/2012/05/1411.jpg"><img class="aligncenter size-full wp-image-1053" title="14" alt="" src="http://rbgeek.files.wordpress.com/2012/05/1411.jpg?w=630&#038;h=177" width="630" height="177" /></a></span></p>
<p>Where <span style="color:#ff0000;">/data/</span> is a directory on local server(<span style="color:#ff0000;">tendo-Srv</span>) and <span style="color:#ff0000;">/backup/</span> is directory on remote server(<span style="color:#ff0000;">tendo-backup</span>) &#38;<span style="color:#ff0000;"> rsynclog.log</span> is a log file at <span style="color:#ff0000;">/rsynclog</span> location, where it will save the log every time after execute the command.</p>
<p>Check the log file:</p>
<pre><span style="color:#ff0000;">cat /rsynclog/rsynclog.log</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/log.jpg"><img class="aligncenter size-full wp-image-1054" title="log" alt="" src="http://rbgeek.files.wordpress.com/2012/05/log.jpg?w=630&#038;h=153" width="630" height="153" /></a></p>
<p>Check the backup on the<span style="color:#ff0000;"> tendo-backup</span> server:</p>
<pre><span style="color:#ff0000;">cd /backup/</span>
<span style="color:#ff0000;">ls</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/154.jpg"><img class="aligncenter size-full wp-image-1056" title="15" alt="" src="http://rbgeek.files.wordpress.com/2012/05/154.jpg?w=630&#038;h=117" width="630" height="117" /></a></p>
<p>Edit the Cron file (Special thanks to <span style="color:#0000ff;">Fernando Flores</span>, to correct the syntax of this command):</p>
<pre><span style="color:#ff0000;">sudo crontab -user arbab -e</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/169.jpg"><img class="aligncenter size-full wp-image-6295" alt="16" src="http://rbgeek.files.wordpress.com/2012/05/169.jpg?w=630&#038;h=193" width="630" height="193" /></a></p>
<p>We need to configure it in such a way that it automatically take the backup at 8 p.m. everyday:</p>
<pre><span style="color:#ff0000;">00 20 * * * rsync -e ssh --progress --partial --delete -avz --log-file=/rsynclog/rsynclog.log /data/ arbab@192.168.1.177:/backup</span></pre>
<p><a href="http://rbgeek.files.wordpress.com/2012/05/173.jpg"><img class="aligncenter size-full wp-image-1063" title="17" alt="" src="http://rbgeek.files.wordpress.com/2012/05/173.jpg?w=630&#038;h=109" width="630" height="109" /></a></p>
<p>Hope this will help you!</p>
<p>Please Remember me in your prayers!</p>
<div id='contact-form-1020'>
<form action='http://rbgeek.wordpress.com/2012/05/22/automatic-backup-from-ubuntu-server-with-rsync/#contact-form-1020' method='post' class='contact-form commentsblock'>
 
<div>
		<label for='g1020-name' class='grunion-field-label name'>Name<span>(required)</span></label>
		<input type='text' name='g1020-name' id='g1020-name' value='' class='name'/>
	</div>
 
<div>
		<label for='g1020-email' class='grunion-field-label email'>Email<span>(required)</span></label>
		<input type='email' name='g1020-email' id='g1020-email' value='' class='email' />
	</div>
 
<div>
		<label for='g1020-website' class='grunion-field-label url'>Website</label>
		<input type='text' name='g1020-website' id='g1020-website' value='' class='url'/>
	</div>
 
<div>
		<label for='contact-form-comment-g1020-comment' class='grunion-field-label textarea'>Comment<span>(required)</span></label>
		<textarea name='g1020-comment' id='contact-form-comment-g1020-comment' rows='20'></textarea>
	</div>
 	<p class='contact-submit'>
		<input type='submit' value='Submit &#187;' class='pushbutton-wide'/>
		<input type="hidden" id="_wpnonce" name="_wpnonce" value="2135a30123" /><input type="hidden" name="_wp_http_referer" value="/tag/backup-with-rsync/feed/" />
		<input type='hidden' name='contact-form-id' value='1020' />
		<input type='hidden' name='action' value='grunion-contact-form' />
	</p>
</form>
</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Backup Data ke Remote Server menggunakan Rsync]]></title>
<link>http://supayagalupa.wordpress.com/2010/12/13/backup-data-ke-remote-server-menggunakan-rsync/</link>
<pubDate>Mon, 13 Dec 2010 09:10:57 +0000</pubDate>
<dc:creator>supayagalupa</dc:creator>
<guid>http://supayagalupa.wordpress.com/2010/12/13/backup-data-ke-remote-server-menggunakan-rsync/</guid>
<description><![CDATA[Skenario: Komputer Lokal: Nama user : opbackup Nama Direktori yang akan di backup : /home/opbackup/c]]></description>
<content:encoded><![CDATA[<h5><strong>Skenario:</strong></h5>
<pre>Komputer Lokal:
Nama user : opbackup
Nama Direktori yang akan di backup : /home/opbackup/coba

Komputer Remote:
Nama user : opbackup
IP Komputer remote : 192.168.1.109
Nama Direktori hasil backup : /home/opbackup/coba
Port SSH : 12345</pre>
<p>Proses backup akan dilakukan melalui ssh. Oleh karena itu perlu public key.</p>
<h5><strong>Membuat Public Key di komputer Local</strong></h5>
<p>Ketik perintah di bawah ini</p>
<pre>$ ssh-keygen -t rsa</pre>
<p>Tekan tombol ENTER sampai 3 kali sehingga muncul tulisan :</p>
<pre>The key fingerprint is:
.....................</pre>
<p>Public key akan diperoleh di directory</p>
<pre>/home/opbackup/.ssh/</pre>
<p>dengan nama file<span style="color:#0000ff;"><em> id_rsa.pub</em></span>. Ubah mode public key tersebut :</p>
<pre>$ chmod 600 /home/opbackup/.ssh/id_rsa.pub</pre>
<p>Copy file <span style="color:#0000ff;"><em>id_rsa.pub</em></span> ke komputer remote dengan nama filenya : <span style="color:#0000ff;"><em>authorized_keys</em></span> yang berada di direktori <span style="color:#0000ff;"><em>/home/opbackup/.ssh/</em></span></p>
<p>(perhatikan karena port SSH komputer remote sudah diganti menjadi <em><span style="color:#0000ff;">port 12345</span></em>, maka pada saat melakukan scp harus menuliskan port-nya dengan menuliskan parameter <em><span style="color:#0000ff;">-P</span></em> )</p>
<pre>$ scp -P 12345 /home/opbackup/.ssh/id_rsa.pub opbackup@192.168.1.109:~/.ssh/authorized_keys</pre>
<p>Jika sudah selesai, coba login ke komputer remote dengan menggunakan user tersebut</p>
<pre>$ ssh -p 12345 opbackup@192.168.1.109</pre>
<p>Jika dapat login di komputer remote tanpa password, berarti proses penyimpanan public key di server telah berhasil.</p>
<h5><strong>Cara melakukan rSync</strong></h5>
<p><em>Sebagai contoh:</em></p>
<p>Kita akan sync folder &#8220;coba&#8221; di home directory local ke home directory remote.<br />
Isi folder &#8220;coba&#8221; di komputer local berisi 1 buah file &#8220;coba.txt&#8221; yang filenya berisi tulisan<br />
&#8220;Percobaan 1&#8243;</p>
<p>Sebelum melakukan proses rsync,lihat dulu isi home directory remote.Untuk saat ini belum ada folder coba<br />
Kemudian lakukan rsync dengan perintah sebagai berikut:</p>
<pre>$ rsync -avzur --stats --delete -e "ssh -p 10022" ~/coba opbackup@192.168.1.109:~

building file list ... done
coba/
coba/coba.txt

Number of files: 2
Number of files transferred: 1
Total file size: 12 bytes
Total transferred file size: 12 bytes
Literal data: 12 bytes
Matched data: 0 bytes
File list size: 85
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 166
Total bytes received: 48

sent 166 bytes  received 48 bytes  428.00 bytes/sec
total size is 12  speedup is 0.06</pre>
<p>Perintah di atas artinya rsync dari folder <em><span style="color:#0000ff;">/home/namauser/coba</span></em> ke folder <em><span style="color:#0000ff;">/home/namauser/</span></em> di komputer remote(192.168.1.109).<br />
Silahkan periksa di folder <span style="color:#0000ff;">/<em>home/namauser/</em></span> di komputer remote. Jika berhasil maka akan ada directory coba dengan 1 buah file bernama <span style="color:#0000ff;">coba.txt</span><br />
Untuk meyakinkan proses rsync berjalan, coba ganti isi file <em>coba.txt</em> di komputer local, kemudian lakukan rsync.</p>
<p>Jika file <span style="color:#0000ff;"><em>coba.txt</em></span> di komputer remote isinya sama dengan file <em><span style="color:#0000ff;">coba.txt</span></em> di local, berarti proses rsync berhasil<br />
Untuk menguji option<span style="color:#0000ff;"><em> &#8211;delete</em></span> :</p>
<p>Buat sebuah file di komputer local, misalnya <span style="color:#0000ff;"><em>coba1.txt</em></span></p>
<p>Lakukan rsync, maka di komputer local akan bertambah 1 buah file lagi, yaitu <em><span style="color:#0000ff;">coba1.txt</span></em></p>
<p>Hapus file <em><span style="color:#0000ff;">coba1.txt</span></em> di komputer local, lalu lakukan rsync,maka file <em><span style="color:#0000ff;">coba1.txt</span></em> di remote akan turut dihapus juga.<br />
Ini fungsi dari option <span style="color:#0000ff;">-<em>-delete</em></span> (digunakan jika komputer remote sebagai mirror komputer local)</p>
<p><strong>Catatan:</strong><br />
Jika ingin report hasil rsync, langsung aja di redirect ke file. Sebagai contoh perintah di bawah ini akan menghasilkan report dengan nama rsync.log yang berada pada home directory user yang melakukan rsync</p>
<pre>$ rsync -avzur --stats --delete -e "ssh -p 10022" ~/coba opbackup@192.168.1.109:~ &#62; ~/rsync.log</pre>
<h3>Hati-hati Garis Miring path Source</h3>
<p>Misalnya</p>
<p>Source dengan nama folder /coba berisi :</p>
<pre>- isi1
  - isi1.txt
- isi2</pre>
<p>Nama folder target : /backupcoba</p>
<p>Jika path source <strong>tidak memakai garis miring</strong></p>
<pre># rsync -av /coba /backupcoba</pre>
<p>Maka hasil di target menjadi</p>
<pre>- backupcoba
  - coba
    - isi1
      - isi1.txt
    - isi2</pre>
<p>Jika path source <strong>menggunakan garis miring</strong></p>
<pre># rsync –av /coba/ /backupcoba</pre>
<p>Maka hasil di target menjadi</p>
<pre>- backupcoba
  - isi1
    - isi1.txt
  - isi2</pre>
<p>Jika <strong>ingin rename directory tujuan</strong></p>
<pre># rsync –av /coba/ /backupcoba/isicoba</pre>
<p>Maka hasil di target menjadi</p>
<pre>- backupcoba
  - isicoba
    - isi1
      - isi1.txt
    - isi2</pre>
<h3>Option Exclude</h3>
<p>Contoh di bawah ini option untuk exclude hidden files</p>
<pre>--exclude=".*/"</pre>
<p>Exclude directory tertentu<br />
Contoh di bawah ini tidak menyertakan directory “isi1”</p>
<pre># rsync –av --exclude ‘isi1’ /coba/ /backupcoba</pre>
<p>Exclude directory berdasarkan pattern tertentu<br />
Contoh di bawah ini tidak menyertakan directory “isi*” dan subdirectorynya</p>
<pre># rsync –av --exclude ‘isi*’ /coba/ /backupcoba</pre>
<p>Exclude directory berdasarkan pattern tertentu<br />
Contoh di bawah ini tidak menyertakan directory “isi*” dan subdirectorynya</p>
<pre># rsync –av --exclude ‘isi*’ /coba/ /backupcoba</pre>
<p>Exclude file tertentu<br />
Contoh di bawah ini tidak menyertakan file isi1.txt</p>
<pre># rsync –av --exclude ‘isi1/isi1.txt’ /coba/ /backupcoba</pre>
<p>Sebagai catatan, directory isi1 “relative” directory sumber</p>
<p>Exclude tipe file tertentu<br />
Contoh di bawah ini tidak menyertakan semua file yang berekstention “txt”</p>
<pre># rsync –av --exclude ‘*.txt’ /coba/ /backupcoba</pre>
<p>Exclude directory dan file tertentu</p>
<p>Buat dahulu sebuah file, misalnya exclude_file.txt yang isinya</p>
<pre>
isi1/isi1.txt
isi2
</pre>
<p>Kemudian gunakan option &#8211;exclude-from namafileexclude </p>
<pre># rsync –av –exclude-from ‘exclude_file.txt’ /coba/ /backupcoba</pre>
]]></content:encoded>
</item>

</channel>
</rss>
