Go Back   Web Server Hosting Forum by BODHost > Support > MySQL Issues.
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-07, 09:16
BOD Member
 
Join Date: Nov 2005
Location: Lancashire, UK
Posts: 82
Default Backup Help Needed.......

Is there any code or script with help of which I can take daily backup of site including MySql databases. Thanx in advance
Reply With Quote
  #2 (permalink)  
Old 03-12-07, 14:13
BodShane's Avatar
Chief Operating Officer
 
Join Date: Dec 2006
Posts: 1,087
Send a message via AIM to BodShane Send a message via MSN to BodShane
Default

If i am not mistaken, you are basically looking for automatic MySQL backups or is it something else. Do let us know more about the same and we will definitely solve in.
__________________
Redundant Dedicated Server Hosting Solutions Only at BODHost
24x7 Toll-Free ph. : +1. 866-662-0909
Email : sales@bodhost.com | MSN : sales@bodhost.com
Reply With Quote
  #3 (permalink)  
Old 03-13-07, 03:50
BOD Member
 
Join Date: Nov 2005
Location: Lancashire, UK
Posts: 82
Default

Quote:
Originally Posted by Admin View Post
If i am not mistaken, you are basically looking for automatic MySQL backups or is it something else. Do let us know more about the same and we will definitely solve in.
Thanx admin for the reply. I am looking for automatic MySQL backups and nothing else.
Reply With Quote
  #4 (permalink)  
Old 07-20-07, 11:57
BOD Member
 
Join Date: Nov 2005
Posts: 131
Smile

Here are some simple steps for data backup in My-Sql:-

First,you have to create a simple script called db backup to backup and compress your database:

#!/usr/bin/bash

mysqldump -uusername -ppassword yourdbname > yourdbname.sql

tar -zcvf sqldata.tgz *.sql

perl /home/emaxx/sqlbk/dbmail.cgi


If you have more than one databases you can repeat line 2 as many times as necessary. Line 3 will simply gzip any .sql files in the directory. You can find full documentation on the mysqldump command on the MySQL.com wesbite.

after thatyou have to create another script called dbmail.cgi to email your gzipped mysqldump results to an address of your choice. In order for this to work, you must have MIME::Lite installed and available to you. Ask your hosting provider to enable it if it isn’t already. Now on to the email script:

#!/usr/bin/perl -w

use MIME::Lite;

$msg = MIME::Lite->new(

From => 'any@address.com',

To => 'my@address.com',

Subject => 'your db backup',

Type => 'text/plain',

Data => "Attached you will find your database backups for today.");

$msg->attach(Type=>'application/x-tar',

Path =>"sqlbackup.tgz",

Filename =>"sqlbackup.tgz");

$msg->send;


Now replace the From and To addresses in lines 6 and 7 and you’re set. If you’d like you could always send to multiple addresses or customize the text in your message.

Now that these two scripts are complete and in place, verify that they work by running the dbbackup script from the shell. If you don’t have shell access to your account, either get it, or skip this step and read on.

Finally, you setup a cron job to run the dbbackup script on a schedule. I

1. 0 3 * * * /full/path/to/dbbackup

That should about do it.

Now you are ready to recieve every day with an email containing your latest database.
Reply With Quote
  #5 (permalink)  
Old 07-20-07, 12:06
BOD Member
 
Join Date: Nov 2005
Location: Lancashire, UK
Posts: 82
Default

Thanks robocop
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 23:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.