Operating System - Linux
1842379 Members
2876 Online
110188 Solutions
New Discussion

Re: howto save daily mysql database from cron ?

 
SOLVED
Go to solution
'chris'
Super Advisor

howto save daily mysql database from cron ?

hi

howto save daily mysql database from cron under linux ?

kind regards
chris
6 REPLIES 6
Jan Sladky
Trusted Contributor
Solution

Re: howto save daily mysql database from cron ?

hi Chris,

#!/bin/bash
59 23 * * * mysqldump db_name >db_name.backup


import into mysql :

mysql db_name < db_name.backup

( db_name.backup is text file with table structure and inserts into table )

hope this will help you

Jan

GSM, Intelligent Networks, UNIX
Stuart Browne
Honored Contributor

Re: howto save daily mysql database from cron ?

I'd suggest you run it through some kind of compression to save a bit of space:

59 23 * * * mysqldump db_name | bzip2 >db_name.backup.bz2

But *shrug* it's just a suggestion.
One long-haired git at your service...
Tijl Dullers_4
Occasional Advisor

Re: howto save daily mysql database from cron ?

Hi,

There is a nice Script/Tool on www.freshmeat.net called mysqlbackup

INstruction on how to schedule this from cron are included in the README files and it is very easy to setup.




'chris'
Super Advisor

Re: howto save daily mysql database from cron ?

you mean

http://unix.freshmeat.net/projects/mysqlbackup/

?

but the download link doesn't work.
'chris'
Super Advisor

Re: howto save daily mysql database from cron ?

hi

I save from cron with:

59 23 * * * root mysqldump -u root --password=password mysql > /opt/save/mysql >/dev/null 2>&1

but howto restore now ?
Stuart Browne
Honored Contributor

Re: howto save daily mysql database from cron ?

mysql -u root --password=password mysql < /opt/save/mysql
One long-haired git at your service...