<?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>Georgi Mitev &#124; Learn Programming Scripts Tutorials &#124; C# ASP .NET MVC &#187; SQL</title>
	<atom:link href="http://georgi-mitev.com/category/sql-mysql-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://georgi-mitev.com</link>
	<description>Georgi Mitev&#039;s blog for scripts, tutorials and something else</description>
	<lastBuildDate>Fri, 02 Mar 2012 01:31:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Full backup of website’s mysql database using cron job</title>
		<link>http://georgi-mitev.com/2010/04/web-development/php/full-backup-mysql-database-db-using-cron-job/</link>
		<comments>http://georgi-mitev.com/2010/04/web-development/php/full-backup-mysql-database-db-using-cron-job/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 09:00:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=226</guid>
		<description><![CDATA[The MySql database backup website backup is very similar to the previous backup that I showed you 2 days ago. We are going to create a php file that is going to dump our database into filename with the current date and time. Ok so let’s get going: 1. Create the file “backup_database.php” and input [...]]]></description>
			<content:encoded><![CDATA[<p>The MySql database backup website backup is very similar to the previous backup that I showed you 2 days ago. We are going to create a php file that is going to dump our database into filename with the current date and time.</p>
<p>Ok so let’s get going:<br />
<strong>1.	Create the file “backup_database.php” and input the following code into it:</strong><br />
&lt;?php exec(&#8216;cd /home/your_user/backup/db/;mysqldump &#8211;add-drop-table -h localhost &#8211;user=your_user &#8211;password=your_pass database_name &gt; `date +%y-%m-%d_%H-%M`.sql&#8217;); ?&gt;</p>
<p>Sometimes the path to your home dir looks different than ‘/home/your_user/’, so execute the ‘pwd’ command like explained in <a href="http://georgi-mitev.com/2010/04/26/schedule-website-file-system-backup-php-cron-job/#more-215">my previous post</a></p>
<p>Here we use the command mysqldump in a tutorial that I wrote previously about the dumping the sql database from one host to another. Now the database will be saved directly on the server that is hosting your website</p>
<p><span id="more-226"></span></p>
<p><strong>2. Create /backup/ and /backup/db/ directories via SSH or  FTP if not created.</strong></p>
<p>Of course you can use any names. But better<strong> do not </strong>create the /backup/ directory in the /public_html/ directory for security reasons <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>3. Upload </strong><strong>“backup_database.php” to the /home/your_user/backup  directtory<br />
</strong></p>
<p>If you upload backup_database.php to www.yoursite.com/backup_database.php by accessing it directly in your browser you will create a backup of your database.  However I do not recommend doing this <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  First because someone can overload your space quota by accessing the backup_database.php many times and second because you probably don’t want to enter the URL in your browser every time you want to perform database backup.</p>
<p><strong>4.	Go to CPanel -&gt; Cron Jobs and input the path to backup_database.php:</strong></p>
<p><img src="http://georgi-mitev.com/images/posts/4.2010/bdb1.jpg" alt="Cron Job DataBase backup" /><br />
Click on the `Add new Cron Job` button…     and you are pimped out. In my case I added the option this cron job to be executed twice a day. In case you database is updated more often/rarely you can modify this setting to suit your needs.<br />
You can also add option to save the dump of the database in tar format to save some space in your hdd quota by changing the script a bit.<br />
Full database backup in tar format (save more space):<br />
backup_database.php:<br />
<strong>&amp;lt;?php exec(&#8216;FILE=`date +%y-%m-%d_%H-%M`;cd /home/ps3igri/backup/db/;mysqldump &#8211;add-drop-table -h localhost &#8211;user=your_mysql_user &#8211;password=your_pass db_name &gt; $FILE.sql;tar czpf $FILE.tar $FILE.sql;rm -f $FILE.sql&#8217;); ?&gt;</strong><br />
As you see here we use the ‘FILE’ variable to store information about the filename. We create a SQL Dump, then we archive it, and after that we delete the original file to save some disk space.<br />
Good luck with the backup and see you next time <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2010/04/web-development/php/full-backup-mysql-database-db-using-cron-job/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>mysql copy entire database to remote host</title>
		<link>http://georgi-mitev.com/2009/04/sql-mysql-scripts/mysql-copy-entire-database-to-remote-host/</link>
		<comments>http://georgi-mitev.com/2009/04/sql-mysql-scripts/mysql-copy-entire-database-to-remote-host/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 12:27:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[backup remote host]]></category>
		<category><![CDATA[copy database]]></category>
		<category><![CDATA[copy database to remote host]]></category>
		<category><![CDATA[db backup mysql]]></category>
		<category><![CDATA[mysqldump command]]></category>
		<category><![CDATA[mysqldump remote host]]></category>
		<category><![CDATA[remote database backup]]></category>
		<category><![CDATA[remote db backup]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=203</guid>
		<description><![CDATA[I needed to create a backup on my mysql database on remote host. I found out that there is a way that you can actually do that with mysqldump . I didn&#8217;t believe that it will be so easy but i decided to give it a try. After all the stuff i read on the [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to create a backup on my mysql database on remote host. I found out that there is a way that you can actually do that with mysqldump <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I didn&#8217;t believe that it will be so easy but i decided to give it a try. After all the stuff i read on the net about it there was&#8217;nt a single working example of it &#8211; so after some testing i managed to do it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
so here it is:</p>
<p>first i will show you how to use mysqldump to backup your database on your harddrive on your local computer under windows. Go to your command prompt -> Start -> Run -> write &#8220;cmd&#8221; -> hit enter<br />
go to your mysql bin directory, in case that you use xampp, and it&#8217;s installed on c:\xampp, it should be in c:\xampp\mysql\bin<br />
you can do that by typing &#8220;cd \&#8221; and then &#8220;cd xampp\mysql\bin&#8221; (i&#8217;m trying to write this tutorial as simple as possible so that everybody will get it <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) </p>
<p>after that, to backup your database on local mashine you should write:<br />
mysqldump &#8211;add-drop-table -h localhost &#8211;user=root &#8211;password=yourpass yourDBname > OutputFile.sql</p>
<p>voilla <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>so if you want to backup your database to remote host the command gets a bit more sophisticated <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
here we go:</p>
<p>copy databse and it&#8217;s data from one server to another:<br />
mysqldump &#8211;user=root &#8211;password=yourPassword &#8211;opt localDB | mysql -h 192.168.1.35 &#8211;user=root &#8211;password=remotePassword remoteDB</p>
<p>In our case we copy our local database &#8220;localDB&#8221; into the database &#8220;remoteDB&#8221; on the machine with 192.168.1.35</p>
<p>we can also do the command like this:<br />
mysqldump -h 192.168.1.17 &#8211;user=test &#8211;password=12345 &#8211;opt remoteDB<br />
 | mysql -h 192.168.1.51 &#8211;user=root &#8211;password=bg_820918 remoteDB</p>
<p>in this case we copy the database &#8220;remoteDB&#8221; from remote host to another remote host in the database &#8220;remoteDB&#8221;</p>
<p>now you see how powerfull mysqldump really is, and that&#8217;s only few of the things it&#8217;s capable of <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I hope this will was usefull for someone <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/04/sql-mysql-scripts/mysql-copy-entire-database-to-remote-host/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

