<?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>dijexi.com &#187; backup</title>
	<atom:link href="http://www.dijexi.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>MySQL Backup to Email</title>
		<link>http://www.dijexi.com/2009/07/mysql-backup-to-email/</link>
		<comments>http://www.dijexi.com/2009/07/mysql-backup-to-email/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 08:52:55 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[mdaemon]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-backup-to-email/</guid>
		<description><![CDATA[Image via CrunchBase This simple PHP script can be used to backup MySQL databases and then send the zipped backup file to email addresses. The backup file can then be restored by any MySQL front end program like the mysql command line, Navicat MySQL, or phpMyAdmin. The logic of the script is really simple: initialization [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><div style="margin: 1em; width: 210px; display: block; float: right" class="zemanta-img"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" alt="Image representing MySQL as depicted in CrunchBase" src="http://www.crunchbase.com/assets/images/resized/0000/1681/1681v1-max-450x450.png" width="162" height="84" />
<p style="font-size: 0.8em" class="zemanta-img-attribution">Image via <a href="http://www.crunchbase.com/">CrunchBase</a></p>
</p></div>
<p>This simple <a class="zem_slink" title="PHP" href="http://php.net/" rel="homepage">PHP</a> script can be used to backup <a class="zem_slink" title="MySQL" href="http://www.mysql.com/" rel="homepage">MySQL</a> databases and then send the zipped backup file to email addresses. The backup file can then be restored by any MySQL front end program like the mysql command line, <a class="zem_slink" title="Navicat" href="http://www.navicat.com/" rel="homepage">Navicat</a> MySQL, or <a class="zem_slink" title="PhpMyAdmin" href="http://www.phpmyadmin.net/" rel="homepage">phpMyAdmin</a>.</p>
<p>The logic of the script is really simple:</p>
<ol>
<li>initialization </li>
<li>create backup sql file </li>
<li>zip the file </li>
<li>send email </li>
</ol>
<p> <span id="more-505"></span>To do the backup automatically you can run the script through cron (*nix) or <a class="zem_slink" title="Task Scheduler" href="http://en.wikipedia.org/wiki/Task_Scheduler" rel="wikipedia">Task Scheduler</a> (<a class="zem_slink" title="Windows" href="http://www.microsoft.com/WINDOWS" rel="homepage">Windows</a>) as described in next section.
</p>
<p>This script uses PHP PEAR library so you need PEAR installed with the Mail and Mail_Mime packages. Read more about PEAR here: <a href="http://pear.php.net/">http://pear.php.net</a>.</p>
<p>This script utilize a ZIP.exe command line program to do the compressing which can be downloaded from <a href="http://stahlforce.com/dev/index.php?tool=zipunzip">http://stahlforce.com/dev/index.php?tool=zipunzip</a>. In *nix environtment you can use tar command line instead to create a tgz file.</p>
<p>Make sure you have write access to the $tmpDir directory.</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">&lt;?</span>php
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">/*********************************************************************\
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">initialization
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">\*********************************************************************/</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #ffa500" href="http://www.php.net/ini_set">ini_set</a>('<span style="color: #8b0000">SMTP</span>','<span style="color: #8b0000">smtp.telkom.net</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/require_once">require_once</a>('<span style="color: #8b0000">Mail.php</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/require_once">require_once</a>('<span style="color: #8b0000">Mail/mime.php</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">// mysql &amp; minor details..</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$mysqlbinpath    = &quot;<span style="color: #8b0000">c:/xampp/mysql/bin</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$tmpDir        = &quot;<span style="color: #8b0000">c:/temp</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$zip        = &quot;<span style="color: #8b0000">c:/xampp/zip/zip.exe</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$user        = &quot;<span style="color: #8b0000">root</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$password    = &quot;<span style="color: #8b0000">pwd</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$dbName        = &quot;<span style="color: #8b0000">db</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$sqlFiles    = &quot;<span style="color: #8b0000"></span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">//databases to backup</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$dbs        = <a style="color: #ffa500" href="http://www.php.net/array">array</a> ('<span style="color: #8b0000">cibpdb</span>', '<span style="color: #8b0000">mysql</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">// email settings...</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$to            = &quot;<span style="color: #8b0000">anemail@gmail.com</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$from        = &quot;<span style="color: #8b0000">anemail@gmail.com</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$subject    = &quot;<span style="color: #8b0000">db - backup</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$attachment    = $tmpDir.'<span style="color: #8b0000">/backup-</span>'.<a style="color: #ffa500" href="http://www.php.net/date">date</a>('<span style="color: #8b0000">Y_M_d-H_i_s</span>') . &quot;<span style="color: #8b0000">.zip</span>&quot;; <span style="color: #008000">// or tgz in *nix</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">/*********************************************************************\
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">create backup sql file and the zip
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">\*********************************************************************/</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/foreach">foreach</a> ($dbs <a style="color: #0000ff" href="http://www.php.net/as">as</a> $dbname)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$sqlFile    = $tmpDir.'<span style="color: #8b0000">/</span>'.$dbname.'<span style="color: #8b0000">-</span>'.<a style="color: #ffa500" href="http://www.php.net/date">date</a>('<span style="color: #8b0000">Y_m_d</span>').&quot;<span style="color: #8b0000">.sql</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/echo">echo</a> &quot;<span style="color: #8b0000">creating $sqlFile\n</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$creatBackup    = $mysqlbinpath . &quot;<span style="color: #8b0000">/mysqldump --add-drop-table -u </span>&quot;.$user.&quot;<span style="color: #8b0000"> --password=</span>&quot;.$password.&quot;<span style="color: #8b0000"> </span>&quot;.$dbname.&quot;<span style="color: #8b0000"> &gt; </span>&quot;.$sqlFile;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #ffa500" href="http://www.php.net/exec">exec</a>($creatBackup);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$sqlFiles    .= '<span style="color: #8b0000"> </span>' . $sqlFile;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">}
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">/*********************************************************************\
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">create the zip file
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">\*********************************************************************/</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/echo">echo</a> &quot;<span style="color: #8b0000">creating $attachment\n</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">//use this command in *nix environment</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">//$createZip    = &quot;tar cvzf $attachment $sqlFiles&quot;;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">//use this command in windows, must have zip.exe</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$createZip    = &quot;<span style="color: #8b0000">$zip $attachment $sqlFiles</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #ffa500" href="http://www.php.net/exec">exec</a>($createZip);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #008000">/*********************************************************************\
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">send zip to email
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">\*********************************************************************/</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/echo">echo</a> &quot;<span style="color: #8b0000">sending $attachment to $to\n</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$headers = <a style="color: #ffa500" href="http://www.php.net/array">array</a>('<span style="color: #8b0000">From</span>' =&gt; $from, '<span style="color: #8b0000">Subject</span>' =&gt; $subject);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$textMessage = $attachment;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$htmlMessage = &quot;<span style="color: #8b0000"></span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$mime = new Mail_Mime(&quot;<span style="color: #8b0000">\n</span>&quot;);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$mime-&gt;setTxtBody($textMessage);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$mime-&gt;setHtmlBody($htmlMessage);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$mime-&gt;addAttachment($attachment, '<span style="color: #8b0000">text/plain</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$body = $mime-&gt;get();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$hdrs = $mime-&gt;headers($headers);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$<a style="color: #ffa500" href="http://www.php.net/mail">mail</a> = &amp;<a style="color: #ffa500" href="http://www.php.net/Mail">Mail</a>::factory('<span style="color: #8b0000">mail</span>');
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$<a style="color: #ffa500" href="http://www.php.net/mail">mail</a>-&gt;<a style="color: #ffa500" href="http://www.php.net/send">send</a>($to, $hdrs, $body);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #ffa500" href="http://www.php.net/unlink">unlink</a>($sqlFile);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #ffa500" href="http://www.php.net/unlink">unlink</a>($attachment);
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><a style="color: #0000ff" href="http://www.php.net/echo">echo</a> &quot;<span style="color: #8b0000">done.</span>&quot;;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"><span style="color: #0000ff">?&gt;</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px"></pre>
</pre>
<p>Please note on the $header above. I&#8217;ve found that PHP mail function failed to send email to a MDaemon SMTP server. If you encounter the same problem, here is the solution that works for me, to change the $header like the following:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">$headers = array(
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'From'            =&gt; $from,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'Reply-To'        =&gt; $from,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-Mailer'        =&gt; 'Microsoft Outlook Express 6.00.2900.5512',
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-Rcpt-To'        =&gt; $to,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-MDRcpt-To'        =&gt; $to,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-MDRemoteIP'        =&gt; '10.5.68.249',
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-Return-Path'        =&gt; $from,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-Envelope-From'    =&gt; $from,
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">'X-MDaemon-Deliver-To' =&gt; $to
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">);</pre>
</pre>
<p>Save the script above to a file for example backup-script.php and save it to a folder for example c:\xampp\</p>
<h2>Setting up Windows Task Scheduler</h2>
<p align="left">
<div style="padding-right: 20px; float: left"><iframe style="border-bottom: medium none; border-left: medium none; border-top: medium none; border-right: medium none" height="600" marginheight="0" border="0" src="http://rcm.amazon.com/e/cm?t=vitrainingcom-20&amp;o=1&amp;p=14&amp;l=st1&amp;mode=books&amp;search=mysql&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" width="160" marginwidth="0" scrolling="no"></iframe></div>
<p><!-- Adsense End --></p>
<p>If you need to run the backup script periodically using the Windows Task Scheduler, do the following steps:</p>
<p>Click on Start – Settings – Control Panel – Scheduled Tasks</p>
<p>Double click Add Scheduled Task</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image8.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb8.png" width="244" height="181" /></a></p>
<p>Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image9.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb9.png" width="244" height="181" /></a></p>
<p>Click Browse… and locate the PHP.EXE executable file, for example C:\<a class="zem_slink" title="XAMPP" href="http://www.apachefriends.org/en/xampp.html" rel="homepage">XAMPP</a>\PHP\PHP.EXE.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image10.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb10.png" width="244" height="181" /></a></p>
<p>Select the execution period of Daily, Weekly, Monthly, etc depending on your backup need. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image11.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb11.png" width="244" height="181" /></a></p>
<p>Select the start time and Date of the task. Also select the daily operation for the task, eg Every Day, Weekdays only, or Every x days. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image12.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb12.png" width="244" height="181" /></a></p>
<p>Next, Enter the username and password that will run the program as. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image13.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb13.png" width="244" height="181" /></a></p>
<h2>Refine the Scheduled Task</h2>
<p>On the dialog, the task periodic schedule is shown, you can refine it by checking “Open advanced properties for this task when I click Finish”. Then click Finish.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/SettingupPHPparameterinTaskScheduler.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Setting up PHP parameter in Task Scheduler" border="0" alt="Setting up PHP parameter in Task Scheduler" src="http://www.dijexi.com/wp-content/uploads/2009/07/SettingupPHPparameterinTaskScheduler_thumb.png" width="218" height="244" /></a></p>
<p>You need to change the Run field from</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">c:\xampp\php\php.exe</pre>
</pre>
<p>to</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">C:\xampp\php\php.exe c:\xampp\htdocs\backup-script.php</pre>
</pre>
<p>You may need to put a double quote on the command line parameter if your script resides on a folder that contains spaces, for example:</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px">C:\xampp\php\php.exe  “C:\Documents <span style="color: #0000ff">and</span> Settings\Toshiba\My Documents\backup-script.php”</pre>
</pre>
<p>This will run php program with an argument, which is our backup script created before.</p>
<p>If you need to adjust the period, you can click on the Schedule tab.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image15.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb15.png" width="410" height="459" /></a></p>
<p>and then click Advanced button</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image16.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb16.png" width="372" height="304" /></a></p>
<p>On the above example, we check on Repeat task, which means we will run the backup program every 6 hours for 24 hours a day, starting from 29 June 2009. Click OK.</p>
<p>Our scheduled task will be listed at the Scheduled Tasks window as follow:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image26.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb26.png" width="504" height="261" /></a></p>
<h2>Run the Scheduled Task</h2>
<p>When you are done, just wait until the schedule for the task to run, or you can right-click on it and click Run to run it now.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image18.png"><img title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb18.png" width="404" height="324" /></a></p>
<p>Backup file created by this periodic backup task can be restored using mysql command line, phpMyAdmin, Navicat MySQL, or other MySQL front end programs.</p>
<p>References:</p>
<ul>
<li>ZIP.EXE download <a href="http://stahlforce.com/dev/index.php?tool=zipunzip">http://stahlforce.com/dev/index.php?tool=zipunzip</a> </li>
<li>PEAR manual <a href="http://pear.php.net/">http://pear.php.net</a> </li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<p>&#160;</p>
<p>Related articles by Zemanta</p>
<div class="zemanta-related">
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://www.mt-soft.com.ar/2009/06/27/how-to-set-up-php-5-with-curl-and-mysql-support-on-windows/">How to set up PHP 5 with Curl and MySQL support on Windows </a>(mt-soft.com.ar) </li>
<li class="zemanta-article-ul-li"><a href="http://oreilly.com/catalog/9780980576818/">Build Your Own Database Driven Web Site Using PHP &amp; MySQL, 4th Edition </a>(oreilly.com) </li>
<li class="zemanta-article-ul-li"><a href="http://www.alistapart.com/articles/indexing-the-web-its-not-just-googles-business/">Indexing the Web &#8211; It&#8217;s Not Just Google&#8217;s Business </a>(alistapart.com) </li>
<li class="zemanta-article-ul-li"><a href="http://themactrack.com/2009/06/25/premiumsoft-introduces-navicat-premium-cross-db-admin-migration-gui/">PremiumSoft introduces Navicat Premium &#8211; Cross DB Admin &amp; Migration GUI </a>(themactrack.com) </li>
</ul>
</div>
<div style="margin-top: 10px; height: 15px" class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/9b05260b-33a1-4b01-9e33-bf191cd2ed8f/"><img style="border-bottom-style: none; border-right-style: none; border-top-style: none; float: right; border-left-style: none" class="zemanta-pixie-img" alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=9b05260b-33a1-4b01-9e33-bf191cd2ed8f" /></a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/" rel="bookmark">Restore MySQL database, stored procedure missing ?</a></li><li><a href="http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/" rel="bookmark">MySQL Backup with phpMyBackupPro</a></li><li><a href="http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/" rel="bookmark">Me-Restore database PostgreSQL dari Windows ke Linux</a></li><li><a href="http://www.dijexi.com/2009/06/codeigniter-konek-ke-port-mysql-tertentu-selain-3306/" rel="bookmark">CodeIgniter: koneksi ke port MySQL tertentu selain 3306</a></li><li><a href="http://www.dijexi.com/2010/07/how-to-send-email-on-java-application-using-javamail-api/" rel="bookmark">How to Send Email on Java Application using JavaMail API</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fmysql-backup-to-email%2F&amp;linkname=MySQL%20Backup%20to%20Email"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/mysql-backup-to-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restore MySQL database, stored procedure missing ?</title>
		<link>http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/</link>
		<comments>http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 23:18:08 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[data directory]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[stored procedure]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/</guid>
		<description><![CDATA[Backing up and Restoring mysql database could be done through several ways. You can backup and restore by exporting SQL script using MySQL command line or copying MySQL data directory from the original server to the destination server. Using the second method will cause the stored procedure and function missing. In this article we will [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>Backing up and Restoring mysql database could be done through several ways. You can backup and restore by exporting SQL script using MySQL command line or copying MySQL data directory from the original server to the destination server.</p>
<p>Using the second method will cause the stored procedure and function missing. In this article we will discuss how to overcome the situation.</p>
<p><span id="more-224"></span></p>
<h2>Backup and Restore using MySQL command line</h2>
<p>You can backup mysql database using mysqldump command line. Using this method, you can backup and restore all information on the database, including the triggers and the stored procedures that you have on the database.</p>
<p>This command line has many parameters, but there are only some of them that we are interested. For example to backup database ialfdb, you use the command:</p>
<blockquote><p><span style="font-family: Courier New; font-size: x-small;">mysqldump ialfdb –u root –p &#8211;add-drop-table &gt; ialfdb.sql</span></p></blockquote>
<p>The above command instruct the system to export SQL statements from the database ialfdb, connecting using username root (-u root), with password that will be asked later (-p), add drop table statement for every table that will be recreated again (—add-drop-table), save the resulting SQL statement to a file named ialfdb.sql in the current directory ( &gt; ialfdb.sql ).</p>
<p>If the system was failed to executed mysqldump program then try to run it using the full path (typing the program’s exact location), for example: c:\xampp\mysql\bin\mysqldump or c:\program files\mysql\bin\mysqldump.</p>
<p>You can specify the destination directory for SQL file for the output by typing the file with it’s full path, for example c:\data\ialfdb.sql.</p>
<p>When the command is executed, it will ask you for a password, that is the password for user specified by –u parameter (root).</p>
<blockquote><p>Enter password:</p></blockquote>
<p>Just type the user’s password. Depending to the size of the database, it will take a while to process your request. After the process is done, you will be back to the command prompt.</p>
<p>Below is a screen capture of the command line session. I used it on Windows operating system, but there will be no big different on other operating system.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image27.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb27.png" border="0" alt="image" width="244" height="125" /></a></p>
<p>To restore the database, you should use the command line mysql. Again we are only interested in a few of all the parameter that the program has. To restore our backup file above (ialfdb.sql), use the command line:</p>
<blockquote><p>mysql ialfdb –u root –p &lt; ialfdb.sql</p></blockquote>
<p>The command line above tell the system to restore the SQL scripts on the file ialfdb.sql ( &lt; ialfdb.sql ), using user root to connect to the database ( –u root ), with password that will be asked later.</p>
<p>If the system was failed to executed mysql program then try to run it using the full path (typing the program’s exact location), for example: c:\xampp\mysql\bin\mysql or c:\program files\mysql\bin\mysql.</p>
<p>You can specify the source directory of the SQL script file by typing the file with it’s full path, for example c:\data\ialfdb.sql.</p>
<p>When the command is executed, it will ask you for a password, that is the password for user specified by –u parameter (root).</p>
<blockquote><p>Enter password:</p></blockquote>
<p>Just type the user’s password. Depending to the size of the database, it will take a while to process your request. After the process is done, you will be back to the command prompt.</p>
<p>Below is a screen capture of the command line session. I used it on Windows operating system, but there will be no big different on other operating system.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image61.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image6_thumb.png" border="0" alt="image" width="244" height="125" /></a></p>
<h2>Backup and Restore by Copying the Data Directory</h2>
<p>You could also backup and restore MySQL database by copying the data directory from a server to other server. By default, MySQL data directory resides on the data directory below the server installation path, for example c:\program files\mysql\data or c:\xampp\mysql\data. There will be directories for your database, in our case is the ialfdb directory.</p>
<p>Simply copy the data directory from the source server to the destination server using Windows Explorer.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image28.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Location of database directory of MySQL database" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb28.png" border="0" alt="Location of database directory of MySQL database" width="430" height="464" /></a></p>
<p>The problem is when your database contains stored procedures and functions. You cannot simply the database directory, but you need also to copy the proc tables under the mysql directory. The files for that tables are: proc.myi, proc.myd, and proc.frm.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image29.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The proc table files" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb29.png" border="0" alt="The proc table files" width="430" height="464" /></a></p>
<p>Of course, other stored procedure and function which are belong to (created at) other database will be copied also in the new database.</p>
<p>That’s all, hope this article is useful for you. Please leave me a comment if you have something to discuss.</p>
<p>Akhmad Daniel Sembiring<br />
<a href="http://www.vitraining.com" target="_blank">vITraining.com</a><br />
<a href="http://ligarwangi.com" target="_blank">Ligarwangi.com &#8211; toserba online</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/" rel="bookmark">Me-Restore database PostgreSQL dari Windows ke Linux</a></li><li><a href="http://www.dijexi.com/2009/06/codeigniter-konek-ke-port-mysql-tertentu-selain-3306/" rel="bookmark">CodeIgniter: koneksi ke port MySQL tertentu selain 3306</a></li><li><a href="http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/" rel="bookmark">MySQL Backup with phpMyBackupPro</a></li><li><a href="http://www.dijexi.com/2009/06/tutorial-membuat-aplikasi-database-ikan/" rel="bookmark">13. Aplikasi Database Ikan</a></li><li><a href="http://www.dijexi.com/2009/08/codeigniter-tutorial-creating-accounting-application-part-3-er-diagram-and-creating-database/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 3 ER Diagram and Creating Database</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F06%2Frestore-mysql-database-stored-procedure-missing%2F&amp;linkname=Restore%20MySQL%20database%2C%20stored%20procedure%20missing%20%3F"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Backup with phpMyBackupPro</title>
		<link>http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/</link>
		<comments>http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 09:44:35 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[apache web server]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[browser ie]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database info]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[manual backup]]></category>
		<category><![CDATA[mysql password]]></category>
		<category><![CDATA[periodic]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Select]]></category>
		<category><![CDATA[sql command]]></category>
		<category><![CDATA[sql data]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/</guid>
		<description><![CDATA[phpMyBackupPro is a tool created using PHP programming language that can be used to perform backup and restore on MySQL database server. In this article we are going to learn how to install and configure this tool, perform manual backup and then perform restore the previously backed up database. We will also learn how to [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>phpMyBackupPro is a tool created using PHP programming language that can be used to perform backup and restore on MySQL database server. In this article we are going to learn how to install and configure this tool, perform manual backup and then perform restore the previously backed up database. We will also learn how to setup an automatic periodic backup using the same tool.</p>
<h2>Installation</h2>
<p>Installation of this tool is simple. Just download the newest version from <a title="http://www.phpmybackuppro.net/download.php" href="http://www.phpmybackuppro.net/download.php">http://www.phpmybackuppro.net/download.php</a>. </p>
<p>After downloading, extract the zip file to a directory on your PHP and Apache web server accessible from browser, ie the Document Root, for example C:\XAMPP\HTDOCS. Then you will get a new folder under it, for example C:\XAMPP\HTDOCS\phpMyBackupPro.</p>
<p>That’s it! Now go to your web browser and point the URL of phpMyBackupPro, for example <a href="http://localhost/phpMyBackupPro">http://localhost/phpMyBackupPro</a>.</p>
<p> <span id="more-192"></span><br />
<h2>Configuration</h2>
<p>After successfully copying the files, and pointing your browser to the URL , you will get a page similar to the following:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image19.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Start Page of phpMyBackupPro" border="0" alt="Start Page of phpMyBackupPro" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb19.png" width="504" height="251" /></a> </p>
<p>As you can see, there are several tabs that we need to explore:</p>
<ol>
<li>Start, the current page, showing the system information </li>
<li>Configuration, the place to do some system configuration </li>
<li>Import, to import recently backed up databases </li>
<li>Backup, to do backing up of databases </li>
<li>Scheduled backup, to create a script to do an automatic backup regularly </li>
<li>Database info, showing detailed database information </li>
<li>SQL query, to do arbitrary SQL command on the server </li>
</ol>
<p>To configuring the system, click on the Configuration tab. You will see a page like the following:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image20.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb20.png" width="504" height="251" /></a> </p>
<p>On that page, you need to adjust the configuration according to your system. That will be:</p>
<ol>
<li>Site name: the name of your site or application to backup </li>
<li>Language: english </li>
<li>SQL Data (<strong>mandatory settings</strong>)
<ol>
<li>MySQL hostname: the host name or IP address of your MySQL server </li>
<li>MySQL username: the user name to connect to your MySQL server </li>
<li>MySQL password: the password for the user name to connect to your MySQL server </li>
<li>only this database: enter the name of the database if you need to backup only that database, otherwise leave it blank so that phpMyBackupPro can backup all of databases on the server </li>
</ol>
</li>
<li>FTP Settings (optional), set it up only if you want to save (upload) the backup file to an FTP server
<ol>
<li>Save backup per FTP server ? check on it if you want to save (upload) the backup file to an FTP server </li>
<li>FTP server, fill with the hostname or IP Address of the FTP server </li>
<li>FTP username: the username to connect to the FTP server </li>
<li>FTP password: the password of the username to connect to the FTP server </li>
<li>FTP path: the location of the backup file on the FTP server </li>
<li>User passive FTP: check it if you are using passive FTP server </li>
<li>FTP Port: the port number of the FTP server, or leave it to 21 for the default number </li>
<li>delete files on FTP server: </li>
</ol>
</li>
<li>Backup per Email, set it up if you want to send the backup file to an email address
<ol>
<li>use email: check it if you want to send the backup file to an email address </li>
<li>email address: enter the email address to receive the backup file </li>
</ol>
</li>
</ol>
</p>
<p>Click on the Save button when you are done.</p>
<p>That’s all for the basic configuration. Your backup system can now be operated to do the backup and restore process from the same URL address. You may check also the Extended Configuration and the System Variables section.</p>
<h2>Performing Manual Backup</h2>
<p>After successfully configure your system, now you can do the backup process. Click on the Backup tab, then a page like the following will be shown:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image21.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb21.png" width="504" height="269" /></a> </p>
<p>You need to do the following steps to backup database(s):</p>
<ol>
<li>Select the database(s) to backup, click on the databases list; to select more than one database, use CTRL-click (press CTRL button on your keyboard and then click your mouse). You may click “select all” to select all of your database listed. </li>
<li>double check the options to
<ol>
<li>“export tables”, whether you want to backup the table definition or not </li>
<li>“export data”, whether you want to backup the table data or not </li>
<li>“add drop table”, whether you want to add the drop table statement or not, before the create table statement </li>
<li>compression, select one of none, gzip, or zip </li>
</ol>
</li>
<li>Select directories to backup to FTP server, select the directory on your FTP server (if you set it up before on the configuration step), or you can add manual FTP directories on the box right to the directory list. You may also check on the “Packed in One ZIP file”. </li>
<li>Click Backup button when you are done. </li>
</ol>
<p>That’s all. You backup is now complete.</p>
<h2>Performing Restore</h2>
<p>To do the restore of a previously backed up database, click on the Import tab. A page similar to the following will show:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image22.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb22.png" width="504" height="273" /></a> </p>
<p>On that page you will see a list several files grouped by the database name corresponding to the backup process. On that list of files, there are some information like the file name, date time the backup is created, and the file size.</p>
<p>To restore a database, simply click “import” link on the file list that correspond to the database to be restored and the date the backup was performed.</p>
<p>There are other options that you can do:</p>
<p>The backup information, clicking the “info” link, will show the following information:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb4.png" width="404" height="291" /></a> </p>
</p>
<p>The SQL statement view, clicking the “view” link, will show the following information:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image23.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb23.png" width="502" height="392" /></a> </p>
<p>To download the backup file, click on the “download” link.</p>
<p>To delete the backup file, click on the “delete” link.</p>
<p align="left"><script type="text/javascript"><!--
google_ad_client = "pub-7773800616131770";
/* horizontal */
google_ad_slot = "1931057994";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p align="left">&#160;</p>
<h2>Performing Scheduled Backup</h2>
<p>To do the backup periodically, go to the Scheduled Backup tab, you will see a page similar to the following:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image24.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb24.png" width="504" height="352" /></a> </p>
<p>You need to do the following steps to setup a periodic backup database(s):</p>
<ol>
<li>Select the backup period: for example: each time the script is called, every 1 hour, every 6 hours, etc. </li>
<li>Select directory where the PHP script file generated will be placed. Leave it to ./ to place the file on the same directory to phpMyBackupPro directory. (You may need to click on “Update directory list”&#160; to refresh the directory listing, in case you create a new directory) </li>
<li>Select the database(s) to backup, click on the databases list; to select more than one database, use CTRL-click (press CTRL button on your keyboard and then click your mouse). You may click “select all” to select all of your database listed. </li>
<li>double check the options to
<ol>
<li>“export tables”, whether you want to backup the table definition or not </li>
<li>“export data”, whether you want to backup the table data or not </li>
<li>“add drop table”, whether you want to add the drop table statement or not, before the create table statement </li>
<li>compression, select one of none, gzip, or zip </li>
</ol>
</li>
<li>Select directories to backup to FTP server, select the directory on your FTP server (if you set it up before on the configuration step), or you can add manual FTP directories on the box right to the directory list. You may also check on the “Packed in One ZIP file”. </li>
<li>Click Show Script button when you are done. </li>
</ol>
<p>The following page will appear:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image25.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb25.png" width="504" height="273" /></a> </p>
<p>The page shows a PHP script to be run to do the backup. Enter the file name for the script, for example script.php, then click Save data. The file will be created on the directory specified at the previuos step.</p>
<p>After it is generated, you can run the script by the following ways:</p>
<ol>
<li>run it using cron tabs (on Linux), or using Task Scheduler (on Windows, see below) </li>
<li>run it using command line </li>
</ol>
<p>That’s all. You backup script is now complete. To restore the backup, do the same way as restoring backup created by manual backup.</p>
<h2>Setting up Windows Task Scheduler</h2>
<h3>Add New Scheduled Task</h3>
<p>If you need to run the backup script periodically using the Windows Task Scheduler, do the following steps:</p>
<p>Click on Start – Settings &#8211; Control Panel – Scheduled Tasks</p>
<p>Double click Add Scheduled Task</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb8.png" width="244" height="181" /></a> </p>
<p>Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb9.png" width="244" height="181" /></a> </p>
<p>Click Browse… and locate the PHP.EXE executable file, for example C:\XAMPP\PHP\PHP.EXE.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb10.png" width="244" height="181" /></a> </p>
<p>Select the execution period of Daily, Weekly, Monthly, etc depending on your backup need. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb11.png" width="244" height="181" /></a> </p>
<p>Select the start time and Date of the task. Also select the daily operation for the task, eg Every Day, Weekdays only, or Every x days. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb12.png" width="244" height="181" /></a> </p>
<p>Next, Enter the username and password that will run the program as. Click Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb13.png" width="244" height="181" /></a> </p>
<h3>Refine the Scheduled Task</h3>
<p>On the dialog, the task periodic schedule is shown, you can refine it by checking “Open advanced properties for this task when I click Finish”. Then click Finish.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb14.png" width="410" height="459" /></a> </p>
<p>You need to change the Run field from</p>
<blockquote><p>c:\xampp\php\php.exe</p>
</blockquote>
<p>to</p>
<blockquote><p>C:\xampp\php\php.exe c:\xampp\htdocs\phpMyBackupPro\script.php db1,db2</p>
</blockquote>
<p>where db1, db2, etc is the database name to backup.</p>
<p>You may need to put a double quote on the command line parameter if your script resides on a folder that contains spaces, for example:</p>
<blockquote><p>C:\xampp\php\php.exe&#160; “C:\Documents and Settings\Toshiba\My Documents\backup\script.php” db1,db2</p>
</blockquote>
<p>This will run php program with an argument, which is our backup script created before.</p>
<p>If you need to adjust the period, you can click on the Schedule tab.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb15.png" width="410" height="459" /></a> </p>
<p>and then click Advanced button</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb16.png" width="372" height="304" /></a> </p>
<p>On the above example, we check on Repeat task, which means we will run the backup program every 6 hours for 24 hours a day, starting from 29 June 2009. Click OK.</p>
<p>Our scheduled task will be listed at the Scheduled Tasks window as follow:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image26.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb26.png" width="504" height="261" /></a> </p>
<h3>Modify the PHP Script</h3>
<p>The final step is to modify the script.php so that the included path is correct. The original script.php file is for example as follow:</p>
<pre style="width: 500px; height: 252px" class="csharpcode">&lt;?php
<span class="rem">// This code was created by phpMyBackupPro v.2.1 </span>
<span class="rem">// http://www.phpMyBackupPro.net</span>
$_POST[<span class="str">'db'</span>]=array(<span class="str">&quot;cibpdb&quot;</span>, <span class="str">&quot;mysql&quot;</span>, );
$_POST[<span class="str">'tables'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'data'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'drop'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'zip'</span>]=<span class="str">&quot;zip&quot;</span>;
$period=(3600*24)/2;
$security_key=<span class="str">&quot;e24c0df313d1cbc9a1e7258811ba5342&quot;</span>;
<span class="rem">// This is the relative path to the phpMyBackupPro v.2.1 directory</span>
@chdir(<span class="str">&quot;../backup/&quot;</span>);
@include(<span class="str">&quot;backup.php&quot;</span>);
?&gt;</pre>
<p>Next, modify line contains @chdir command to point to the correct absolute folder where the phpMyBackupPro folder (the file named backup.php) resides, for example:</p>
<pre style="width: 500px; height: 252px" class="csharpcode">&lt;?php
<span class="rem">// This code was created by phpMyBackupPro v.2.1 </span>
<span class="rem">// http://www.phpMyBackupPro.net</span>
$_POST[<span class="str">'db'</span>]=array(<span class="str">&quot;cibpdb&quot;</span>, <span class="str">&quot;mysql&quot;</span>, );
$_POST[<span class="str">'tables'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'data'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'drop'</span>]=<span class="str">&quot;on&quot;</span>;
$_POST[<span class="str">'zip'</span>]=<span class="str">&quot;zip&quot;</span>;
$period=(3600*24)/2;
$security_key=<span class="str">&quot;e24c0df313d1cbc9a1e7258811ba5342&quot;</span>;
<span class="rem">// This is the relative path to the phpMyBackupPro v.2.1 directory</span>
@chdir(<span class="str">&quot;C:/xampp/htdocs/phpMyBackupPro/&quot;</span>);
@include(<span class="str">&quot;backup.php&quot;</span>);
?&gt;</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<h3>Run the Scheduled Task</h3>
<p>When you are done, just wait until the schedule for the task to run, or you can right-click on it and click Run to run it now.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/image18.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2009/06/image_thumb18.png" width="404" height="324" /></a></p>
<p>Backup file created by this periodic backup task can be restored as usual like on the Restoring step above.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/" rel="bookmark">Restore MySQL database, stored procedure missing ?</a></li><li><a href="http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/" rel="bookmark">Me-Restore database PostgreSQL dari Windows ke Linux</a></li><li><a href="http://www.dijexi.com/2009/07/mysql-backup-to-email/" rel="bookmark">MySQL Backup to Email</a></li><li><a href="http://www.dijexi.com/2009/06/codeigniter-konek-ke-port-mysql-tertentu-selain-3306/" rel="bookmark">CodeIgniter: koneksi ke port MySQL tertentu selain 3306</a></li><li><a href="http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/" rel="bookmark">MySQL Transpose Row Into Column</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F06%2Fmysql-backup-with-phpmybackuppro%2F&amp;linkname=MySQL%20Backup%20with%20phpMyBackupPro"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Me-Restore database PostgreSQL dari Windows ke Linux</title>
		<link>http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/</link>
		<comments>http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 22:46:00 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[backup database]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[message transfer]]></category>
		<category><![CDATA[port database]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[winscp]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/</guid>
		<description><![CDATA[Kasus Anda mempunyai database PostgreSQL yang sudah berjalan di Windows kemudian ingin direstore ke server PostgreSQL yang berjalan di Linux. Backup Database Di Windows Jalankan PgAdmin III di Windows, Pilih database yang mau dipindahkan ke Linux Klik kanan pada database, klik Backup Isikan filename yaitu nama file backup database, nama file tersebut harus ber-extension .backup [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><h2>Kasus</h2>
<p>Anda mempunyai database PostgreSQL yang sudah berjalan di Windows kemudian ingin direstore ke server PostgreSQL yang berjalan di Linux.</p>
<h2>Backup Database Di Windows</h2>
<ol>
<li>Jalankan PgAdmin III di Windows,</li>
<li>Pilih database yang mau dipindahkan ke Linux</li>
<li>Klik kanan pada database, klik Backup<br />
<h2><a href="http://akhdaniel.files.wordpress.com/2008/04/backup.png"><img class="alignnone size-medium wp-image-8" style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; vertical-align: middle; border-left-width: 0px" src="http://akhdaniel.files.wordpress.com/2008/04/backup.png?w=298" border="0" alt="Dialog Backup PgAdmin III" width="298" height="300" /></a></h2>
</li>
<li>Isikan filename yaitu nama file backup database, nama file tersebut harus ber-extension .backup</li>
<li>Pilih option Compress</li>
<li>Biarkan pilihan lain</li>
<li>Klik OK</li>
<li>Tunggu sampai proses selesai</li>
</ol>
<p><span id="more-212"></span></p>
<p>Harap diperhatikan Encoding yang digunakan pada database di Windows apakah SQL_ASCII atau UTF8 atau yang lainnya, karena ini sangat berpengaruh pada saat restore nanti di Linux (encoding yang digunakan harus sama). Encoding database dapat dilihat dari properties database seperti gambar di bawah:</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/04/db-properties.png"><img class="aligncenter size-medium wp-image-10" style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://akhdaniel.files.wordpress.com/2008/04/db-properties.png?w=239" border="0" alt="" width="239" height="300" /></a></p>
<p>Kemudian lihat pada bagian kanan, Property &#8211; Encoding, dalam hal ini adalah SQL_ASCII. Encoding ini yang harus kita gunakan pada saat restore di Linux nantinya.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/04/encoding.png"><img class="aligncenter size-medium wp-image-11" style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://akhdaniel.files.wordpress.com/2008/04/encoding.png?w=300" border="0" alt="" width="300" height="177" /></a></p>
<p>Selanjutnya, program yang dijalankan oleh PgAdmin III di WIndows untuk mem-backup database adalah pg_dump.exe dengan parameter sbb:</p>
<pre style="width: 509px; height: 58px;">pg_dump.exe -i -h localhost -p 5432 -U postgres -F t -b -v –f 

       "c:\tmp\tes.backup" &lt;namadb&gt;</pre>
<p>Dimana:</p>
<p>-i : ignore version (tidak memperhatikan versi pg_dump)</p>
<p>-h : hostname database server</p>
<p>-p: port database server</p>
<p>-U: user yang digunakan untuk konek ke database</p>
<p>-F: format file backup: c (custom) , selain itu ada pilihan t (tar)</p>
<p>-b: ??</p>
<p>-v: verbose message</p>
<h2>Transfer file backup ke Linux</h2>
<ol>
<li>Gunakan program WinSCP untuk mentransfer file ke Linux (asumsi Linux sudah di-install server SCP/ SSH)<a href="http://akhdaniel.files.wordpress.com/2008/04/winscp.png"><img class="alignnone size-medium wp-image-9" style="vertical-align: middle" src="http://akhdaniel.files.wordpress.com/2008/04/winscp.png?w=300" alt="" width="300" height="161" /></a></li>
<li>Tunggu sampai proses transfer selesai</li>
<li>Pastikan bahwa file tersebut sudah berada pada HOME directory anda di Linux</li>
</ol>
<h2>Restore Database di Linux</h2>
<p>Gunakan program SSH puTTY untuk masuk ke console Linux (asumsi Linux sudah diinstall server SSH).</p>
<p>Buat database baru tempat menampung hasil restore menggunakan program psql sebagai berikut (ketikkan perintah yang ditulis dalam huruf bold):</p>
<pre><strong>psql -U postgres </strong>
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# <strong>CREATE DATABASE test_restore ENCODING='SQL_ASCII';</strong>
CREATE DATABASE
postgres=# <strong>\q</strong></pre>
<p>Pada HOME directory jalankan program pg_restore sbb:</p>
<pre><strong>pg_restore -U postgres -d </strong><strong><strong>test_restore</strong></strong><strong> -F c &lt;nama_file_backup&gt;</strong></pre>
<p>Dimana:</p>
<p>-d: nama database tujuan restore</p>
<p>-U : user yang digunakan untuk konek ke database</p>
<p>-F : format yang digunakan untuk me-restore file backup, harus sesuai dengan format yang digunakan untuk mem-backup</p>
<p>Tunggu sampai proses restore selesai.</p>
<p style="text-align: right">22 April 2008</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/" rel="bookmark">Restore MySQL database, stored procedure missing ?</a></li><li><a href="http://www.dijexi.com/2009/06/perl-konek-ke-postgresql/" rel="bookmark">Perl connection to PostgreSQL</a></li><li><a href="http://www.dijexi.com/2009/06/meng-connect-in-php-ke-postgresql/" rel="bookmark">PHP Connection to PostgreSQL</a></li><li><a href="http://www.dijexi.com/2009/06/adempiere-opensource-erp-installation/" rel="bookmark">001 Adempiere Opensource ERP Installation</a></li><li><a href="http://www.dijexi.com/2009/06/mysql-backup-with-phpmybackuppro/" rel="bookmark">MySQL Backup with phpMyBackupPro</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2008%2F04%2Fme-restore-database-postgresql-dari-windows-ke-linux%2F&amp;linkname=Me-Restore%20database%20PostgreSQL%20dari%20Windows%20ke%20Linux"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2008/04/me-restore-database-postgresql-dari-windows-ke-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
