<?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>Tips for Twits &#187; cron</title>
	<atom:link href="http://t.wits.sg/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://t.wits.sg</link>
	<description>WARNING: excessive use of this site will increase MP at the expense of HP</description>
	<lastBuildDate>Mon, 14 Jun 2010 01:55:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>HOWTO: Scheduled Remote MySQL Backups</title>
		<link>http://t.wits.sg/2008/06/18/howto-scheduled-remote-mysql-backups/</link>
		<comments>http://t.wits.sg/2008/06/18/howto-scheduled-remote-mysql-backups/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 08:30:43 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[db]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=13</guid>
		<description><![CDATA[If you have more access to more than 1 server, a good idea would be to schedule remote backups using a small script and crontab. This way, if 1 server goes down at least SOME data still resides on another. (a friend&#8217;s hosting service got prematurely terminted recently because someone else sharing a hosting plan [...]]]></description>
			<content:encoded><![CDATA[<p>If you have more access to more than 1 server, a good idea would be to schedule remote backups using a small script and crontab. This way, if 1 server goes down at least SOME data still resides on another. (a friend&#8217;s hosting service got prematurely terminted recently because someone else sharing a hosting plan was serving illegal content and the whole system was confiscated by the police in that country!)</p>
<p>of course backing up mysql is the only thing you can do, unless you&#8217;ve way too much disk space and way too much bandwidth&#8230; in that case please consult a professional on the actual 1001 ways to throw money at redundancy.</p>
<p>The script will first run remote commands on the target server over ssh to dump and gzip the database into a file. The file is then downloaded to the backup server. A final ssh command removes the dump file from the target server. Viola! And here is the shell script&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">ssh root@wits.sg 'mysqldump -uroot twits&gt; /tmp/twits.backup.sql &amp;&amp; bzip2 -9 /tmp/twits.backup.sql'
scp root@wits.sg:/tmp/twits.backup.sql.bz2 /var/backups/twits/`date &quot;+%Y%m%d-%H%M&quot;`.sql.bz2
ssh root@wits.sg 'rm /tmp/twits.backup.sql.bz2'</pre></div></div>

<p>Save this few lines to a file on the backup server and give it execute permissions! (I saved it at /root/twits_backup.sh)<br />
<strong>Note:</strong> <a href="http://t.wits.sg/2008/06/15/howto-passwordless-logins-between-servers/">Passwordless logins between the 2 servers</a> must have been setup prior to running this script. Otherwise scp and ssh commands will both be prompted for a password.</p>
<p>Next set up the cron job on the backup server to run the script</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">30 05 * * * /root/twits_backup.sh</pre></div></div>

<p>This sets the script to run at 5:30am everyday.<br />
<a href="http://crunchbang.org/archives/2007/10/26/howto-setup-a-crontab-file/">Here</a> is a good place to read up more on cron jobs.</p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2008/06/18/howto-scheduled-remote-mysql-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
