Backing up and restoring Java WebApp configuration

I have a Java Spring MVC web application. And it has some config and properties files.

There is a directory, let's say myappconf . Inside there are configuration and properties folders. There are some files inside.

myappconf
  |
  |---conf
  |    |
  |    |__ settings.xml
  |    |__ nodes.xml
  |
  |---prop
       |
       |__ app.properties 

      

I want to backup my entire folder to a different location. I already have Quartz to run some other Jobs. I can use the same to create backups. To the specified location, I can copy the entire folder at a specific interval or when any file has been modified.

I am running my application in tomcat.

In case of application crash or server crash, I want to install a new application on the server and restore the configuration. There is also some data in the folder. I want to restore everything.

I don't know how to restore it. Has anyone implemented something like this? or does anyone have some guidelines for backup and recovery?

thank

+3


source to share


2 answers


I would do it this way -

  • If you can save the state of the application every time it is loaded / deployed to a database or file, that is, it has just been installed or restored.
  • If you are using linux platform, go and update the file startup.sh

    that starts when tomcat starts.
  • Assuming only one application is running in your tomcat instance, you can check the file or database record you created in step 1 during server startup.
  • If this entry states that any previous configuration exists, just deploy it to your application, if not, start a new application.


This will continue recursively until you manually delete the entry you created in step 1.

Hope it helps.

+2


source


Yup, you can just copy the files to the War Exploded directory. You can use quartz if you like, or you can use any file system backup tool. It may be easier later because it has recovery options.

In case you are running your own tools (eg quartz) to "restore", you will stop your tomcat instance, copy the files into place, optionally restarting the old ones, and re-enable tomcat. Tomcat reads from exploded war files, so you should be good to go.



Edit: Ideally, you would have to disable tomcat (gracefully) before copying the files to make sure that if any changes to those files that were in memory have been cleared, but in practice this is rarely a problem with these kinds of files ( my opinion).

+1


source







All Articles