automatic backup mysql databases

As you can see, I want a script that I can automatically back up my databases. For example I want to back up db1, db3, db4, not backing up the db2. How to do it?

What I mean: not to dump it to .sql but to .gzip or .tar.gz only, without dumping. I want to do it every six hours.
 
# mysqldump -u user -p password database | gzip > mybackup.gz
 
What I want is compressing the database folder as it is
Code:
.frm
.MYD
.MYI
Compressing it as it is without dumping. I want a script to do it. I used AutoMySQLBackup but it saved it as .sql file.
Hope you have an answer.
 
Do you just want to copy the files where the database is stored? Why do you want to do this? The files might not be consistent, there might be problems with restoring etc etc.

What is the real problem that you want to solve? Why are the .sql-files not ok?
 
Store your /mysql directory in a ZFS pool and use snapshots for the backups.
Send the snapshots to a different location compressed or native.

Hope that helps.
 
Keep in mind that you can indeed just backup the files from a MyISAM database. However, it does NOT work when dealing with InnoDB.

In short, mysqldump is the only way to back up properly.
 
I need a backup of the files as it is. So please if anyone has a script that can do such a thing I'll be grateful.

Thank you all for your help.
 
How hard can it be?

# tar -zcvf my_db_backup.tgz /var/mysql/
 
Thanks SirDice, but what I want is a function that generate the folder and .tar.gz name.

Thanks in advance.
 
Yeah, you're supposed to learn how it works then do it yourself. We're not the spoon-feeding types.
 
UNIXgod said:
Wouldn't you rather be self sufficient? Seriously.

For 50 USD per hour, as a relatively simple one time task: I would probably ask to have it done.

On that note, since I wouldn't expect it to be a one off problem, I would learn how to do it. But since it wasn't me who asked the question in the first place, the question is moot.
 
mix_room said:
But since it wasn't me who asked the question in the first place, the question is moot.

I see I mis quoted.

almobd3 said:

almobd3 if you are interested in scripting your own policies I am with most certainty that many here, including myself, would be more than happy to teach you.
 
Back
Top