LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-23-2008, 10:34 AM   #1
Hammad101
Member
 
Registered: Dec 2005
Posts: 72

Rep: Reputation: 15
Script to Backup MySQL Database on Server Automatically ?


Hi.

I have a Debian etch server and looking for some automatic ways to backup a vBulletin Mysql Database daily or 12-Hr.

I'm not concerrned about auto-backup slowing down the server for the duration of back (well read somewhere).

also I would want the filename to be date-based.

maybe a bash script or something ... as i would like to add the following in it too
Code:
perl rsapi.pl {sql filename dumped}
so the DB gets uploaded to my rapidshare account automatically.

any help will be greatly appreciated.

Last edited by Hammad101; 12-23-2008 at 10:53 AM.
 
Old 12-23-2008, 10:39 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You can use tar and cron
 
Old 12-23-2008, 10:54 AM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Code:
#!/bin/bash
#

date=$(date +%F)
backupdir=/some/dir/to/place/backups/to

cd $backupdir
/usr/bin/mysqldump -u <username> -p<password> --databases <database> > database-name_$date.sql
gzip database-name_$date.sql # optional to compress
It's simple but works. Play around with it and come up with something that suits to your needs.
 
Old 12-23-2008, 10:55 AM   #4
Hammad101
Member
 
Registered: Dec 2005
Posts: 72

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by repo View Post
You can use tar and cron
thanks for the reply but if i knew CORN ......

i've updated the OP also.
 
Old 12-23-2008, 11:03 AM   #5
Hammad101
Member
 
Registered: Dec 2005
Posts: 72

Original Poster
Rep: Reputation: 15
thanks alot trickykid.

I'll check it out and let you know.
 
Old 12-23-2008, 11:20 AM   #6
Hammad101
Member
 
Registered: Dec 2005
Posts: 72

Original Poster
Rep: Reputation: 15
ok it works great!

thanks again

but how do i setup a CORN JOB for it?

sorry i've got no idea.
 
Old 12-23-2008, 11:54 AM   #7
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by Hammad101 View Post
ok it works great!

thanks again

but how do i setup a CORN JOB for it?

sorry i've got no idea.
Either throw it in your /etc/cron.daily or /etc/cron.hourly folders if you have those available or manually setup the cron job by doing a crontab -e
 
Old 12-23-2008, 12:52 PM   #8
Hammad101
Member
 
Registered: Dec 2005
Posts: 72

Original Poster
Rep: Reputation: 15
Thanks a lot mate.

This is what i'm going to use.

Code:
59 23 * * * /usr/bin/backup >> /var/log/db.backup.log 2>&1
Will backup every day @ midnight. and maintain a log too.
(posted if someone else stumbles across might be of some help)
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create backup MYSQL Script to backup my database for every 1hour RMLinux Linux - Newbie 3 11-20-2008 10:13 AM
backup mysql database nawuza Linux - Newbie 17 08-25-2008 02:40 PM
LXer: Backup MySQL databases, web server files to a FTP server automatically LXer Syndicated Linux News 0 08-11-2006 09:54 PM
How to import a mysql database from backup WindowBreaker Slackware 6 03-16-2006 11:08 PM
Need script to dump database, ftp file to backup server glock19 Linux - Networking 17 05-12-2003 05:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration