Is there any embedded database/files backup framework for Java?
I'm trying to find a Java library/framework, which I can add to my WAR and enable regular backup of files and databases (started on my own timer). I don't want to use a standalone solution for backup (located/maintained apart from my WAR), mostly because it's bigger maintenance headache.
Do you know any such libraries?
Hmm.. Possible but which database are you using? If you are using JavaDb or Apache Derby you already have all the tools you need. You can make a JDBC call to make backups. Here is the code:
String sqlstmt = "CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)";
CallableStatement cs = conn.prepareCall(sqlstmt);
cs.setString(1,"D:/dbbackups/");
cs.execute();
cs.close();
And for scheduling the backup tasks you can make use of Quartz. It is free, opensource and a good job scheduler. If you use some other DB you can still call the command using the System.exec method from the scheduler task.
精彩评论