<?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>Chris Tate-Davies &#187; backups</title>
	<atom:link href="http://www.christatedavies.co.uk/tag/backups/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christatedavies.co.uk</link>
	<description>An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring...</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to use mysqldump</title>
		<link>http://www.christatedavies.co.uk/2011/01/18/how-to-use-mysqldump/</link>
		<comments>http://www.christatedavies.co.uk/2011/01/18/how-to-use-mysqldump/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 14:22:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=130</guid>
		<description><![CDATA[Using mysqldump to back up a database If you want to make a super quick backup of a MySQL database, the best tool for the job is the native mysqldump. Its also a command line utility, so you can use it from a telnet or SSH connection, etc&#8230; The basic command structure of mysqldump is: [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/01/18/how-to-use-mysqldump/' addthis:title='How to use mysqldump ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<h3>Using mysqldump to back up a database</h3>
<p>If you want to make a super quick backup of a MySQL database, the best tool for the job is the native mysqldump. Its also a command line utility, so you can use it from a telnet or SSH connection, etc&#8230;</p>
<p>The basic command structure of mysqldump is:</p>
<pre>mysqldump -u {username} -p{password} {database} &gt; {backup-file}</pre>
<p>I.e. If you had root access, and you wanted to backup all the tables within the &#8220;customers&#8221; database you could run this command:</p>
<pre>mysqldump -u root -p customers &gt; mybackup.sql</pre>
<p>This would dump all the data to the mybackup.sql file. Note I didn&#8217;t enter a password. Mysql will ask you for your password in this instance. If you wanted to enter the password (where it could be seen, or saved into a BASH history) then you use the command -pABC123 where ABC123 is the password (not the lack of a space between -p and ABC123 &#8211; this is important!)</p>
<p>But if you are security conscious, omit the actual password from the command line, and merely use -p as this will prompt you for the password and therefore BASH or DOS will not store it.</p>
<p>If you wanted to only dump certain tables from the database, specify them after the database. For example, to back up the &#8220;address&#8221; and &#8220;billing&#8221; tables:</p>
<pre>mysqldump -u root -p customers address billing &gt; mybackup.sql</pre>
<h3>Restoring a mysqldump file</h3>
<p>If you want to restore a mysqldump&#8217;ed file into MySQL &#8211; you can simply run the following command:</p>
<pre>mysql -u {username} -p{password} {database} &lt; {backup-file}</pre>
<p>Note the change of direction for the &lt; symbol and the fact we&#8217;re calling the mysql command, and not the mysqldump command!!!</p>
<p>So, to squirt my backupfile back into the customers database</p>
<pre>mysql -u root -pABC123 customers &lt; mybackup.sql</pre>
<p>NB. This will overwrite your current database tables with whatever is in the backupfile!</p>
<h3>Using mysqldump to backup ALL databases</h3>
<p>If you have lots of databases, then you simply use the &#8211;all-databases command to back them all up into one file:</p>
<pre>mysqldump -u root -pABC123 --all-databases &gt; mytotalbackup.sql</pre>
<h3>Using mysqldump to backup multiple databases</h3>
<p>By using the &#8211;databases switch, we can state which databases we want backed up. Separate each database name with a space.</p>
<p>So to backup &#8220;customers&#8221;, &#8220;orders&#8221; and &#8220;misc&#8221; we use the following syntax:</p>
<pre>mysqldump -u root -pABC123 --databases customers orders misc &gt; multiple-databases.sql</pre>
<h3>Advanced techniques</h3>
<p><strong>Compressed backups</strong></p>
<p>More often than not, a database dump will be several hundred MB in size, if not more. MySQL can zip this for you automatically using the gzip command:</p>
<pre>mysqldump -u root -pABC123 customers | gzip &gt; compressed-backup.sql.gz</pre>
<p>The pipe before the gzip tells mysqldump to send the output to the next command, which is gzip and that, in turn, is asked to create &#8220;compressed-backup.sql.gz&#8221;</p>
<p><strong>Dumping the data definitions</strong></p>
<p>If you wanted a &#8220;skeleton&#8221; structure of the entire database, then mysqldump will allow this, by using the &#8211;no-data switch:</p>
<pre>mysql -u root -pABC123 --no-data customers &gt; customers-structure.sql</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/01/18/how-to-use-mysqldump/' addthis:title='How to use mysqldump ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/01/18/how-to-use-mysqldump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading the MySQL binary log</title>
		<link>http://www.christatedavies.co.uk/2010/07/27/reading-the-mysql-binary-log/</link>
		<comments>http://www.christatedavies.co.uk/2010/07/27/reading-the-mysql-binary-log/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 15:28:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[binary log]]></category>
		<category><![CDATA[mysqlbinlog]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=97</guid>
		<description><![CDATA[Having MySQL dumping out binary logs is a very good failsafe for backup redundancy. But, how do you get any of the information out of them? If you know a time span that you need to investigate, then you can easily use the mysqlbinlog utility: mysqlbinlog --start-datetime="2010-07-27 14:30:00" --stop-datetime="2010-07-27 15:00:00" &#62; backup.txt This will export [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/07/27/reading-the-mysql-binary-log/' addthis:title='Reading the MySQL binary log ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Having MySQL dumping out binary logs is a very good failsafe for backup redundancy. But, how do you get any of the information out of them?</p>
<p>If you know a time span that you need to investigate, then you can easily use the mysqlbinlog utility:</p>
<pre>mysqlbinlog --start-datetime="2010-07-27 14:30:00" --stop-datetime="2010-07-27 15:00:00" &gt; backup.txt</pre>
<p>This will export all the recorded SQL Statements performed between 2:30pm and 3pm on the 27th July 2010 to the text file &#8220;backup.txt&#8221;. I can then browse at my convenience.</p>
<p>If you need to re-create any of the statements, you can copy and paste into your MySQL client of choice.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/07/27/reading-the-mysql-binary-log/' addthis:title='Reading the MySQL binary log ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/07/27/reading-the-mysql-binary-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

