<?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>dan.thoughts &#187; backup</title>
	<atom:link href="http://blog.sosedoff.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sosedoff.com</link>
	<description>Web-development, PHP, Ruby, Sinatra, Merb, Rails, MySQL, SQLite, Web Services.</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:54:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Date separated MySQL backups</title>
		<link>http://blog.sosedoff.com/2009/09/18/date-separated-mysql-backups/</link>
		<comments>http://blog.sosedoff.com/2009/09/18/date-separated-mysql-backups/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 14:04:59 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=163</guid>
		<description><![CDATA[Here is the bash shell script that makes archived dumps of your database server. All databases are separated from each other and stored into date based folders. 

#!/bin/bash

MyUSER="root"
MyPASS=""
MyHOST="localhost"
NOW="$(date +"%d-%m-%Y")"
STOREDIR="/home/storage/backup/database/by_dates/$NOW"
DBLIST="$(mysql -u $MyUSER -h $MyHOST -Bse 'show databases')"

[ ! -d $STOREDIR ] &#038;&#038; mkdir -p $STOREDIR &#124;&#124; :

for db in $DBLIST
do
	FILE="$STOREDIR/$db.gz"
	mysqldump -u $MyUSER -h $MyHOST $db &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the bash shell script that makes archived dumps of your database server. All databases are separated from each other and stored into date based folders. </p>
<pre>
#!/bin/bash

MyUSER="root"
MyPASS=""
MyHOST="localhost"
NOW="$(date +"%d-%m-%Y")"
STOREDIR="/home/storage/backup/database/by_dates/$NOW"
DBLIST="$(mysql -u $MyUSER -h $MyHOST -Bse 'show databases')"

[ ! -d $STOREDIR ] &#038;&#038; mkdir -p $STOREDIR || :

for db in $DBLIST
do
	FILE="$STOREDIR/$db.gz"
	mysqldump -u $MyUSER -h $MyHOST $db | gzip -9 > $FILE
done
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/09/18/date-separated-mysql-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple MySQL backup script</title>
		<link>http://blog.sosedoff.com/2009/01/15/simple-mysql-backup-script/</link>
		<comments>http://blog.sosedoff.com/2009/01/15/simple-mysql-backup-script/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 13:02:33 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=27</guid>
		<description><![CDATA[There is a small useful ruby script to backup your MySQL databases in small projects, where speed of backup not so important.
Source:

#!/usr/bin/ruby
# MySQL Backup Utility
# Usage: ./mysql_backup.rb or ruby mysql_backup.rb
&#160;
$backup_archive = true # gzip files after processing
$backup_dir = &#34;/home/storage/backup/&#34; # output directory
$backup_template = &#34;project-%s-%s.sql&#34; # text-%dbname-%timestamp.sql
$backup_cmd = &#34;mysqldump -u local_backup --add-drop-table --databases %s &#38;gt; %s&#34;
$backup_dblist [...]]]></description>
			<content:encoded><![CDATA[<p>There is a small useful ruby script to backup your MySQL databases in small projects, where speed of backup not so important.<br />
Source:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/ruby</span>
<span style="color: #666666; font-style: italic;"># MySQL Backup Utility</span>
<span style="color: #666666; font-style: italic;"># Usage: ./mysql_backup.rb or ruby mysql_backup.rb</span>
&nbsp;
<span style="color: #007800;">$backup_archive</span> = <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #666666; font-style: italic;"># gzip files after processing</span>
<span style="color: #007800;">$backup_dir</span> = <span style="color: #ff0000;">&quot;/home/storage/backup/&quot;</span> <span style="color: #666666; font-style: italic;"># output directory</span>
<span style="color: #007800;">$backup_template</span> = <span style="color: #ff0000;">&quot;project-%s-%s.sql&quot;</span> <span style="color: #666666; font-style: italic;"># text-%dbname-%timestamp.sql</span>
<span style="color: #007800;">$backup_cmd</span> = <span style="color: #ff0000;">&quot;mysqldump -u local_backup --add-drop-table --databases %s &amp;gt; %s&quot;</span>
<span style="color: #007800;">$backup_dblist</span> = <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #666666; font-style: italic;"># list of databases to backup</span>
  <span style="color: #ff0000;">'main'</span>,
  <span style="color: #ff0000;">'users'</span>,
  <span style="color: #ff0000;">'admin'</span>,
  <span style="color: #ff0000;">'cards'</span>
<span style="color: #7a0874; font-weight: bold;">&#93;</span> 
&nbsp;
def backup_database<span style="color: #7a0874; font-weight: bold;">&#40;</span>database<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">time</span> = Time.now<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  time_str = sprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;%02i-%02i-%04i-%02i%02i%02i&quot;</span>,time.day, time.month, time.year, time.hour, time.min, time.sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  filename = sprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$backup_template</span>,database,time_str<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  filename = <span style="color: #ff0000;">&quot;#{<span style="color: #007800;">$backup_dir</span>}#{filename}&quot;</span>
&nbsp;
  cmd = sprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$backup_cmd</span>,database,filename<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">if</span> system<span style="color: #7a0874; font-weight: bold;">&#40;</span>cmd<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span>
    system<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;gzip --best #{filename}&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">$backup_archive</span>
  end
end
&nbsp;
<span style="color: #007800;">$backup_dblist</span>.each <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">|</span>db<span style="color: #000000; font-weight: bold;">|</span>
  puts <span style="color: #ff0000;">&quot;Processing database... #{db}&quot;</span>
  backup_database<span style="color: #7a0874; font-weight: bold;">&#40;</span>db<span style="color: #7a0874; font-weight: bold;">&#41;</span>
end</pre></div></div>

<p>Paste: <a href="http://pastie.org/341839">http://pastie.org/341839</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/01/15/simple-mysql-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

