Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

This is easy to do.

  1. Write a script to create the backup using the "mysqldump" tool available at - 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


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.