Backing Up Your Database Using Spring Data

I need to schedule a regular database backup for my web application using Spring. Does Spring provide specific backup support? I plan to use TaskScheduler and TaskExecutor.

+5
source share
1 answer

No, there is no specific support for this. Spring Data is for transactional use, not for batch operations. Of course, there is a method findAll()that you can iterate over and store the results somewhere.

Spring Package is probably a little better choice as it focuses on long, heavy batch processes. But IMHO, your application is not a good place to back up. Why not use database or OS support? It will be faster and more reliable.

If you really need to back up your database from the application level, review the database manual, there may be some simple command to dump the contents of the database into a file. For example, inI use the SCRIPTSQL command from JdbcTemplateto upload the database to an arbitrary file. But I use this method to reset the database after each integration test . I use JdbcTemplateto minimize overhead. That's why Spring Data is not the best tool for the job.

MySQL mysqldump, Java .

+6

All Articles