Unix Technical Forum

Cron Backup of Database

This is a discussion on Cron Backup of Database within the MySQL forums, part of the Database Server Software category; --> Can anyone give me a link containing data that explains the correct procedure for setting up a batch file ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:33 AM
Fred Atkinson
 
Posts: n/a
Default Cron Backup of Database

Can anyone give me a link containing data that explains the
correct procedure for setting up a batch file to backup and InnoDB
database and set that file to execute using Cron on my Website?

Regards,



Fred
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:33 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Cron Backup of Database

On Wed, 20 Feb 2008 13:01:07 -0500, Fred Atkinson wrote:
> Can anyone give me a link containing data that explains the
> correct procedure for setting up a batch file to backup and InnoDB
> database and set that file to execute using Cron on my Website?


crontab -e

Make it look something like:

# Back up altgothic database conveniently.
49 22 * * * mysqldump -uthe_user -pthe_password --opt --databases altgothic >~/tmp/altgothic`date +\%d`.sql


This one runs every day at 22:49, stores data in a rotating set of
backup files. User your own appropriate options. From this point, the
automatic backing up of the homedirs to tape solves the rest of the
problem.

--
"The last refuge of the insomniac is a sense of superiority to the
sleeping world."
--Leonard Cohen, The Favourite Game
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:33 AM
Fred Atkinson
 
Posts: n/a
Default Re: Cron Backup of Database

On Wed, 20 Feb 2008 12:58:55 -0600, "Peter H. Coffin"
<hellsop@ninehells.com> wrote:

>On Wed, 20 Feb 2008 13:01:07 -0500, Fred Atkinson wrote:
>> Can anyone give me a link containing data that explains the
>> correct procedure for setting up a batch file to backup and InnoDB
>> database and set that file to execute using Cron on my Website?

>
>crontab -e
>
>Make it look something like:
>
># Back up altgothic database conveniently.
>49 22 * * * mysqldump -uthe_user -pthe_password --opt --databases altgothic >~/tmp/altgothic`date +\%d`.sql
>
>
>This one runs every day at 22:49, stores data in a rotating set of
>backup files. User your own appropriate options. From this point, the
>automatic backing up of the homedirs to tape solves the rest of the
>problem.


I'm not very experienced with Cron. I was attempting to do it
in CPanel at the Cron icon. I would surely appreciate a link to
directions on how to do it that way.

Regards,




Fred



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:33 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Cron Backup of Database

On Wed, 20 Feb 2008 16:19:24 -0500, Fred Atkinson wrote:
> On Wed, 20 Feb 2008 12:58:55 -0600, "Peter H. Coffin"
><hellsop@ninehells.com> wrote:
>
>>On Wed, 20 Feb 2008 13:01:07 -0500, Fred Atkinson wrote:
>>> Can anyone give me a link containing data that explains the
>>> correct procedure for setting up a batch file to backup and InnoDB
>>> database and set that file to execute using Cron on my Website?

>>
>>crontab -e
>>
>>Make it look something like:
>>
>># Back up altgothic database conveniently.
>>49 22 * * * mysqldump -uthe_user -pthe_password --opt --databases altgothic >~/tmp/altgothic`date +\%d`.sql
>>
>>
>>This one runs every day at 22:49, stores data in a rotating set of
>>backup files. User your own appropriate options. From this point, the
>>automatic backing up of the homedirs to tape solves the rest of the
>>problem.

>
> I'm not very experienced with Cron. I was attempting to do it
> in CPanel at the Cron icon. I would surely appreciate a link to
> directions on how to do it that way.


Sorry, never touch the stuff, personally. I'm very much a CLI kind of
fellow.

--
94. When arresting prisoners, my guards will not allow them to stop and grab a
useless trinket of purely sentimental value.
--Peter Anspach's list of things to do as an Evil Overlord
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 11:33 AM
Fred Atkinson
 
Posts: n/a
Default Re: Cron Backup of Database

On Wed, 20 Feb 2008 16:21:17 -0600, "Peter H. Coffin"
<hellsop@ninehells.com> wrote:

>On Wed, 20 Feb 2008 16:19:24 -0500, Fred Atkinson wrote:
>> On Wed, 20 Feb 2008 12:58:55 -0600, "Peter H. Coffin"
>><hellsop@ninehells.com> wrote:
>>
>>>On Wed, 20 Feb 2008 13:01:07 -0500, Fred Atkinson wrote:
>>>> Can anyone give me a link containing data that explains the
>>>> correct procedure for setting up a batch file to backup and InnoDB
>>>> database and set that file to execute using Cron on my Website?
>>>
>>>crontab -e
>>>
>>>Make it look something like:
>>>
>>># Back up altgothic database conveniently.
>>>49 22 * * * mysqldump -uthe_user -pthe_password --opt --databases altgothic >~/tmp/altgothic`date +\%d`.sql
>>>
>>>
>>>This one runs every day at 22:49, stores data in a rotating set of
>>>backup files. User your own appropriate options. From this point, the
>>>automatic backing up of the homedirs to tape solves the rest of the
>>>problem.

>>
>> I'm not very experienced with Cron. I was attempting to do it
>> in CPanel at the Cron icon. I would surely appreciate a link to
>> directions on how to do it that way.

>
>Sorry, never touch the stuff, personally. I'm very much a CLI kind of
>fellow.


My hosting provider solved it. Here is the final script (with the
names of the user, password, and the database file changed for
security reasons):

#!/bin/sh
# a script to dump the 'special' database to a file
MYSQL=`which mysqldump`
DATE=`date +%y%m%d`
OUTPUT=/home/fred/database_backups/special_$DATE
${MYSQL} -ufred -ppassword -B siteusername_special -Q -c
--add-drop-table >${OUTPUT}.sql

I set it to run as a cron job. It seems to be working now.

Regards,


Fred
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 On
Forum Jump


All times are GMT. The time now is 01:41 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com