Take the 2-minute tour ×

We are developing a Java web application using Spring, Hibernate and MySQL.

I want our application to automatically backup the MySQL database daily; is there any way to accomplish that with Java code?

share|improve this question
u may use one facility of mysql that can be rollback the data of your database –  Dhaiwat budh Sep 9 '12 at 17:44

2 Answers 2

This is easy to do.

  1. Write a script to create the backup using the "mysqldump" tool available at http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html - Google "mysql backup unix/windows script" to find some examples.

  2. Use a task scheduler to run this script. On UNIX this could be "cron", Windows as a "task scheduler". Best to do so at times when the app is under low-usage.

It is worth while putting some backup file cycling into the script so that you keep, say, every backup from the last week and delete the rest.

Also remember to backup to a physically different disk from the database itself so you have a backup if the disk dies.

share|improve this answer

You can user Quartz-scheduler to schedule the backup, take a look here on how to schedule an automatic Hibernate backup.

share|improve this answer

Your Answer


