Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

hey I am newbie to scripting in linux.I want to take a sqldump of my database every hour, I have gone thorough couple of blogs i was able to write a script which will take the dump of my database but I do I make it run every hour in the crontab.

Kindly help me out.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

taking dump of database every hour is not a good option. if size of database is large, then most of system resources would be busy in just taking dump every hour. better consider INCREMENTAL backups, in which you only backup the changed area of the database and not the whole database.

Making Incremental Backups by Enabling the Binary Log

MySQL supports incremental backups: You must start the server with the --log-bin option to enable binary logging. The binary log files provide you with the information you need to replicate changes to the database that are made subsequent to the point at which you performed a backup. At the moment you want to make an incremental backup (containing all changes that happened since the last full or incremental backup), you should rotate the binary log by using FLUSH LOGS. This done, you need to copy to the backup location all binary logs which range from the one of the moment of the last full or incremental backup to the last but one. These binary logs are the incremental backup; at restore time, you apply them, “Point-in-Time (Incremental) Recovery Using the Binary Log”. The next time you do a full backup, you should also rotate the binary log using FLUSH LOGS, mysqldump --flush-logs, or mysqlhotcopy --flushlog.

for different types of backups in mysql, goto this url:

http://dev.mysql.com/doc/refman/5.1/en/backup-methods.html

share|improve this answer

You will use cron for this. Edit your crontab and add something like

* /1 * * * <your script>

To edit your crontab, use

crontab -e
share|improve this answer
1  
<your script> = mysqldump or a wrapped version of it. –  Antoine Benkemoun Nov 12 '11 at 8:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.