<?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>BG Tech Blog &#187; Lab</title>
	<atom:link href="http://bgtechblog.com/category/lab/feed/" rel="self" type="application/rss+xml" />
	<link>http://bgtechblog.com</link>
	<description>Проблемите, с които се сблъскваме всеки ден</description>
	<lastBuildDate>Fri, 18 May 2012 22:33:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>bash script за бекъп (backup) на база данни</title>
		<link>http://bgtechblog.com/2009/11/14/bash-script-%d0%b7%d0%b0-%d0%b1%d0%b5%d0%ba%d1%8a%d0%bf-backup-%d0%bd%d0%b0-%d0%b1%d0%b0%d0%b7%d0%b0-%d0%b4%d0%b0%d0%bd%d0%bd%d0%b8/</link>
		<comments>http://bgtechblog.com/2009/11/14/bash-script-%d0%b7%d0%b0-%d0%b1%d0%b5%d0%ba%d1%8a%d0%bf-backup-%d0%bd%d0%b0-%d0%b1%d0%b0%d0%b7%d0%b0-%d0%b4%d0%b0%d0%bd%d0%bd%d0%b8/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 09:44:07 +0000</pubDate>
		<dc:creator>Благомир Иванов</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Lab]]></category>

		<guid isPermaLink="false">http://bgtechblog.com/?p=178</guid>
		<description><![CDATA[В момента съм в процес на ъпгрейд на бекъп системата ми. Не се учудвайте ако видите нещо да е &#8220;не както трябва&#8221;, защото все пак цялата система е писана за лични нужди и скоро няма изгледи да бъде пусната за масово ползване. За пореден път: авторите на блога не отговарят за щетите, които може да [...]]]></description>
			<content:encoded><![CDATA[<p>В момента съм в процес на ъпгрейд на бекъп системата ми. Не се учудвайте ако видите нещо да е &#8220;не както трябва&#8221;, защото все пак цялата система е писана за лични нужди и скоро няма изгледи да бъде пусната за масово ползване.</p>
<p><em>За пореден път: авторите на блога не отговарят за щетите, които може да нанесете на системата си, използвайки и прилагайки статиите написани тук!</em></p>
<p>Ето го и скрипта <img src='http://bgtechblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">DBUSER</span>=<span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #007800;">DBPASS</span>=<span style="color: #ff0000;">&quot;password_here&quot;</span>
<span style="color: #007800;">DIR</span>=<span style="color: #ff0000;">&quot;/home/blagomir/test/&quot;</span>
<span style="color: #007800;">DUMP</span>=<span style="color: #ff0000;">&quot;/usr/bin/mysqldump&quot;</span>
&nbsp;
&nbsp;
<span style="color: #007800;">DATABASES</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$DBUSER</span> -p<span style="color: #007800;">$DBPASS</span> <span style="color: #660033;">-e</span><span style="color: #ff0000;">&quot;show databases&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">for</span> b <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$DATABASES</span> ;
	<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #007800;">TABLES</span>=<span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-u</span> <span style="color: #007800;">$DBUSER</span> -p<span style="color: #007800;">$DBPASS</span> <span style="color: #660033;">-e</span><span style="color: #ff0000;">&quot;show tables from <span style="color: #007800;">$b</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;==============================================&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup database <span style="color: #007800;">$b</span>&quot;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TABLES</span> ;
	<span style="color: #000000; font-weight: bold;">do</span>
&nbsp;
		<span style="color: #007800;">VARIABLE</span>=<span style="color: #ff0000;">&quot;Tables_in_<span style="color: #007800;">$b</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VARIABLE</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #007800;">$t</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup table <span style="color: #007800;">$b</span>.<span style="color: #007800;">$t</span>&quot;</span>
			<span style="color: #007800;">$DUMP</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$DBUSER</span> -p<span style="color: #007800;">$DBPASS</span> <span style="color: #660033;">--database</span> <span style="color: #007800;">$b</span> <span style="color: #660033;">--table</span> <span style="color: #007800;">$t</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$DIR</span><span style="color: #007800;">$b</span>.<span style="color: #007800;">$t</span>.sql
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done backup <span style="color: #007800;">$b</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;==============================================&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

No tags for this post.]]></content:encoded>
			<wfw:commentRss>http://bgtechblog.com/2009/11/14/bash-script-%d0%b7%d0%b0-%d0%b1%d0%b5%d0%ba%d1%8a%d0%bf-backup-%d0%bd%d0%b0-%d0%b1%d0%b0%d0%b7%d0%b0-%d0%b4%d0%b0%d0%bd%d0%bd%d0%b8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rsync &#8211; push или pull &#8211; Тестът!</title>
		<link>http://bgtechblog.com/2009/11/10/rsync-push-%d0%b8%d0%bb%d0%b8-pull-%d1%82%d0%b5%d1%81%d1%82%d1%8a%d1%82/</link>
		<comments>http://bgtechblog.com/2009/11/10/rsync-push-%d0%b8%d0%bb%d0%b8-pull-%d1%82%d0%b5%d1%81%d1%82%d1%8a%d1%82/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 20:05:18 +0000</pubDate>
		<dc:creator>Благомир Иванов</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://bgtechblog.com/?p=137</guid>
		<description><![CDATA[След като написах предният пост, реших сам да направя теста споменат там. /remote/path/ OS: Ubuntu 9.10 CPU: Intel 2.6 GHz HDD: Hitachi 500 GB (7200 rpm) /local/path/ OS: Ubuntu 9.10 CPU: Intel Core Duo x 1.86 GHz HDD: 120 GB (5400 rpm) Първи опит: rsync pull Source: /remote/path/ Destination: /local/path/ 1 2 3 4 5 [...]]]></description>
			<content:encoded><![CDATA[<p>След като написах предният пост, реших сам да направя теста споменат там.</p>
<p><strong>/remote/path/</strong><br />
OS: Ubuntu 9.10<br />
CPU: Intel 2.6 GHz<br />
HDD: Hitachi 500 GB (7200 rpm)</p>
<p><strong>/local/path/</strong><br />
OS: Ubuntu 9.10<br />
CPU: Intel Core Duo x 1.86 GHz<br />
HDD: 120 GB (5400 rpm)</p>
<p><strong>Първи опит: rsync pull</strong><br />
Source: /remote/path/<br />
Destination: /local/path/</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">blagomir<span style="color: #000000; font-weight: bold;">@</span>dragonfly:<span style="color: #000000; font-weight: bold;">/</span>storage<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ rsync <span style="color: #660033;">--stats</span> <span style="color: #660033;">-a</span> blagomir<span style="color: #000000; font-weight: bold;">@</span>192.168.1.2:<span style="color: #000000; font-weight: bold;">/</span>remote<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>
blagomir<span style="color: #000000; font-weight: bold;">@</span>192.168.1.2<span style="color: #ff0000;">'s password: 
&nbsp;
Number of files: 26579
Number of files transferred: 23604
Total file size: 1211767628 bytes
Total transferred file size: 1211709797 bytes
Literal data: 1211709797 bytes
Matched data: 0 bytes
File list size: 583070
File list generation time: 0.091 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 460461
Total bytes received: 1213463704
&nbsp;
sent 460461 bytes  received 1213463704 bytes  2425422.91 bytes/sec
total size is 1211767628  speedup is 1.00</span></pre></td></tr></table></div>

<p>До тук приключва и първата част от теста. Лошото е само, че не можах да разбера колко секунди отне въпросният трансфер&#8230;<br />
Кратка калкулация 1211709797 / 2425422.91 = 499.587017177 сек.</p>
<p><strong>Втори опит: rsync push</strong><br />
Source: /local/path/<br />
Destination: /remote/path/</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">blagomir<span style="color: #000000; font-weight: bold;">@</span>dragonfly:<span style="color: #000000; font-weight: bold;">/</span>storage<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ rsync <span style="color: #660033;">--stats</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span> blagomir<span style="color: #000000; font-weight: bold;">@</span>192.168.1.2:<span style="color: #000000; font-weight: bold;">/</span>remote<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>
blagomir<span style="color: #000000; font-weight: bold;">@</span>192.168.1.2<span style="color: #ff0000;">'s password: 
&nbsp;
Number of files: 26574
Number of files transferred: 23604
Total file size: 1211709797 bytes
Total transferred file size: 1211709797 bytes
Literal data: 1211709797 bytes
Matched data: 0 bytes
File list size: 588640
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1213459369
Total bytes received: 460367
&nbsp;
sent 1213459369 bytes  received 460367 bytes  2469826.52 bytes/sec
total size is 1211709797  speedup is 1.00
blagomir@dragonfly:/storage/test$</span></pre></td></tr></table></div>

<p>При вторият вариант цифрите са следните:<br />
1211709797 / 2469826.52 = 490.605225585 сек.</p>
<p><strong>Заключение:</strong> при проведеният тест се установи, че <strong>rsync</strong> работи по-бързо при <strong>push</strong> отколкото при <strong>pull</strong>. Това се случи при мен с много на брой, но малки файлове.<br />
Ако имате свободно време и желание можете да тествате и вие и да публикувате резултатите си тук.</p>
No tags for this post.]]></content:encoded>
			<wfw:commentRss>http://bgtechblog.com/2009/11/10/rsync-push-%d0%b8%d0%bb%d0%b8-pull-%d1%82%d0%b5%d1%81%d1%82%d1%8a%d1%82/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

