Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 19-10-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
  How to backup your MYSQL Database

Evening All,

My database has grown to about 7MB on a table. I used to backup and restore with no problems but I'm doing this manually and as the tables have grown I've noticed the backups don't include all the rows! Schwepps! How do you lot backup your data everynight and restore it? fcron jobs??

My info is I'm using MYSQL held on an ISP server.

Regs,

NM.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 19-10-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
If your server has cpanel you can do it through the backup option on the menu then "Download a MySQL Database Backup" alternatively you should be able to do it with phpmyadmin.

Regards
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 19-10-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
Yeah I use phpmyadmin but that's when I started seeing lines missed off. What I'm after is something automatic how do you do it?

NM.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 19-10-06
Registered User
 
Join Date: Sep 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
monkeyboy is an unknown quantity at this point
Check out mysqldump

http://www.unixcities.com/mysql/mysqldump.html
__________________
Prezzybox.com home of the gift wizard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 19-10-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
I work the other way round. ie my main data files are kept and updated on my computer then I upload them to my site.

I've written a script for one of my customer that enables him to download his database in an xml file but his database is not all that big.

One way you could do it is to write a script to create a csv file on your server. something along these lines.

PHP Code:
open  database etc
<?php
$fp
=fopen("backup.csv","w");
$sql="SELECT * FROM table";
$result mysql_query($sql) or die("Query failed : " mysql_error());
while(
$datamysql_fetch_array($result,MYSQL_NUM))
{
$csv=implode("'",$data);
fwrite($fp,$csv);
}
fclose($fp);
?>
You will need to change the permissions of the directory to which you want to write the file.

Regards
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 19-10-06
Lynx's Avatar
Penny wise...!
 
Join Date: Aug 2005
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Lynx is an unknown quantity at this point
You could automate a daily backup using a cronjob

Quote:
mysqldump --user=DB_USER --password=PASSWORD --quick --add-drop-table --add-locks --extended-insert --lock-tables --all DB_NAME | gzip > /home/directory/to_store_backup/bkup-`date -I`.gz
Same as above: You will need to change the permissions of the directory to which you want to write the file.


L.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 20-10-06
andylink's Avatar
learning slowly
 
Join Date: Jan 2006
Location: Norfolk
Posts: 76
Thanks: 0
Thanked 1 Time in 1 Post
andylink is an unknown quantity at this point
I too use a cronjob and mysqldump to a backup server.

Andy
__________________
The Pessimist complains ABOUT THE WIND; The optimist expects it to CHANGE; The realist adjusts the SAIL - William A Ward
http://www.gift-inspirations.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #8 (permalink)  
Old 20-10-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
Ok,

I like the sound of the backup by cron job (as my users add data to the database so it can't be on my computer). Only problem is when I try to import the dumped file through mysql\Apache running on Windows XP it comes up with "No SQL Query"?? WTF!

I have changed php.ini to accept larger files etc etc. Any ideas?

Regs,

NM.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 20-10-06
Sandis's Avatar
MoreNiche.Com
 
Join Date: Jun 2006
Posts: 126
Thanks: 0
Thanked 0 Times in 0 Posts
Sandis is an unknown quantity at this point
Great tips guys! I like that CSV approach a lot uh.. these programmers
__________________
&nbsp;
Earn up to 175$ per sale with MoreNiche.Com
Free Templates, Free Content, Free Marketing Guides, Fantastic Affiliate Support

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 24-10-06
Registered User
 
Join Date: Jun 2004
Location: Yorkshire
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
OnlineMerchants seems to know their stuff
Hi,

Well I have to backup a few databases and it may be more than
you need but I use this - and it's brilliant to be honest

http://sourceforge.net/projects/automysqlbackup/

I run the above on a daily cron job and then once the above is complete
I have added another script that tar's up all the backups and copies them
to another server. The second script called world wide backup can be
found here: http://www.worldwidecreations.com/freescripts5.htm

You may be able to just use the second one for your needs??

HTH

Cheers

Steve
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #11 (permalink)  
Old 24-10-06
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
Many thanks, just what I'm looking for.

Ta,

NM.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)