<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: bash code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 20 Aug 2008 21:23:29 GMT</pubDate>
    <description>DZone Snippets: bash code</description>
    <item>
      <title>Backup MySQL databases into seperate files</title>
      <link>http://snippets.dzone.com/posts/show/988</link>
      <description>A cronable script for backing up all your databases as seperate files.  I'd suggest limiting the backup user's access to the IP of the computer backing up, and using some sort of encryption if you're on a capable version of mysql.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# MySQL backups from the Data&lt;br /&gt;&lt;br /&gt;MOUNTED=`grep /etc/mtab -e \/mnt\/backup`&lt;br /&gt;if [ "$MOUNTED" = '' ]; then&lt;br /&gt;        echo "/mnt/backup is not mounted, there is no drive to backup to"&lt;br /&gt;        exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mkdir -p /mnt/backup/cluster_sql&lt;br /&gt;&lt;br /&gt;for i in $(echo 'SHOW DATABASES;' | mysql -ubackup -pSUPERSECRET -hData|grep -v '^Database$'); do&lt;br /&gt;  mysqldump -ubackup -pSUPERSECRET -hData --opt $i &gt; /mnt/backup/cluster_sql/$i.sql;&lt;br /&gt;done;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 20 Dec 2005 12:50:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/988</guid>
      <author>mixonic (Matthew Beale)</author>
    </item>
  </channel>
</rss>
