<?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>zoe.vc &#187; Email</title>
	<atom:link href="http://www.zoe.vc/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zoe.vc</link>
	<description>development &#38; freelancing blog</description>
	<lastBuildDate>Mon, 30 Jan 2012 07:03:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Backup Skript mit Emailversand.</title>
		<link>http://www.zoe.vc/2009/mysql-backup-skript-mit-emailversand/</link>
		<comments>http://www.zoe.vc/2009/mysql-backup-skript-mit-emailversand/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 17:30:41 +0000</pubDate>
		<dc:creator>Alex (zoe.vc)</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zoe.vc/?p=69</guid>
		<description><![CDATA[A while ago I found a good script for backing up a MySQL database and sending it via email to a recipient here. The script is cool, but I didn't like its structure and the fact, that you have to add the database values inline and that it can only backup a single database. For [...]]]></description>
			<content:encoded><![CDATA[<div class="jLanguage">
<ul>
<li><a href="?lan=english"><img alt="english" src="http://www.zoe.vc/wp-content/plugins/jLanguage/icons/en.png" /></a></li>
<li><a href="?lan=german"><img alt="german" src="http://www.zoe.vc/wp-content/plugins/jLanguage/icons/de.png" /></a></li>
</ul>
</div>
<p>A while ago I found a good script for backing up a MySQL database and sending it via email to a recipient <a href="http://www.gmeditor.com/wiki/code-downloads/mysql-backup/">here</a>.</p>
<p>The script is cool, but I didn't like its structure and the fact, that you have to add the database values inline and that it can only backup a single database. For this reason I rewrote it a little and you can download it here.</p>
<p>Features:</p>
<ul>
<li>Backup of mutliple databases</li>
<li>Sending of backups to multiple users</li>
</ul>
<p>For every single database a mail is send and there is no file saved on the server. And wow: it's really easy to configure!</p>
<p>How do I use it?</p>
<ul>
<li><a href="http://www.zoe.vc/misc/mysqlbackup-0.1.rar">Download the current version (0.1)</a><a rel="attachment wp-att-73" href="http://www.zoe.vc/?attachment_id=73"> </a></li>
<li>Adjust the backup.php (you're getting help by my wonderful comments)</li>
<li>upload everything to a directory of your choice</li>
<li>if applicable, create a cronjob to periodically execute the script</li>
</ul>
<p>And here the backup.php that calls the appropriate classes and executes the backup (also included in the download):</p>
<pre class="php"><a href="http://www.php.net/ini_set"><span style="color: #000066;">ini_set</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'error_reporting'</span>, <span style="color: #000000; font-weight: bold;">E_ALL</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// include the files</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">'MySQLConfig.php'</span>;
<span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">'MySQLBackup.php'</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// add some databases to backup</span>
<span style="color: #808080; font-style: italic;">// the domain will be appended to the email subject and is also included within the sql file for identification.</span>
<span style="color: #0000ff;">$cfgHost0</span> = <span style="color: #000000; font-weight: bold;">new</span> MySQLConfig<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'username0'</span>, <span style="color: #ff0000;">'password0'</span>, <span style="color: #ff0000;">'database_name0'</span>, <span style="color: #ff0000;">'domain0'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$cfgHost1</span> = <span style="color: #000000; font-weight: bold;">new</span> MySQLConfig<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'username1'</span>, <span style="color: #ff0000;">'password1'</span>, <span style="color: #ff0000;">'database_name1'</span>, <span style="color: #ff0000;">'domain1'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$backup</span> = <span style="color: #000000; font-weight: bold;">new</span> MySQLBackup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// the path to the directory where this script is resided</span>
<span style="color: #0000ff;">$backup</span>-&amp;gt;setExecutionPath<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/srv/domain/backup/'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// add the database configs to backup</span>
<span style="color: #0000ff;">$backup</span>-&amp;gt;addDatabaseToBackup<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cfgHost0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$backup</span>-&amp;gt;addDatabaseToBackup<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cfgHost1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// the sender of the backup mail</span>
<span style="color: #0000ff;">$backup</span>-&amp;gt;setSender<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin@yourdomain.com'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// add some people to receive the backup</span>
<span style="color: #0000ff;">$backup</span>-&amp;gt;addRecipient<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'john@yourdomain.com'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$backup</span>-&amp;gt;addRecipient<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'frank@yourdomain.com'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// execute the whole thing</span>
<span style="color: #0000ff;">$backup</span>-&amp;gt;backup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>If there are any problems or suggestions or feature wishes, please comment this post - thanks!</p>
<p>PS: to create a cronjob log into your server using SSH, then execute "crontab -e" to edit the crontab and insert for example "0 2 * * 0,3 wget http://yourdomain.com/backup/backup.php -nc -q -O /dev/null" for an execution on sunday and wednesday at 2 am. Save and close the whole thing with ":wq" and that's it <img src='http://www.zoe.vc/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoe.vc/2009/mysql-backup-skript-mit-emailversand/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

