Hi.
I have written a grails program, and I needed a database backup/restore
mechanism, so I wrote something to dump and restore the database using XML
serialization. Wrote a service that does the backup dump/restore. Wrote
integration tests to check that things worked, and they do.
Then I figured that I should create a couple of scripts to do dump/restore.
Simple enough I thought. The dump script works fine, dumps things to stdout.
The restore script probably does the right thing (judging from trace
output), but the database remains unchanged. It seems that the changes I do
in the restore script are not committed. Any ideas about where I should
look for enlightenment?
(I'm using grails 1.1-RC2 on wxp sp3)
The dumper script:
==============
includeTargets << grailsScript("Init")
includeTargets << grailsScript("Bootstrap")
target(main: "Restore the content of the database from an XML file") {
depends( configureProxy, packageApp, classpath, parseArguments,
bootstrap)
// configure and load application
bootstrap();
configureApp();
def backupService = appCtx.getBean("backupService"
);
System.out.println("Backup is = " +
backupService.newBackupWriter().toString());
}
setDefaultTarget(main)
The restore script:
=============
includeTargets << grailsScript("Init")
includeTargets << grailsScript("Bootstrap")
target(main: "Restore the content of the database from an XML file") {
depends( configureProxy, packageApp, classpath, parseArguments,
bootstrap)
// configure and load application
bootstrap();
configureApp();
// Get the backup service bean
def backupService = appCtx.getBean("backupService");
// Read everything from standard input
StringBuffer sb = new StringBuffer();
new BufferedReader(new InputStreamReader(System.in)).eachLine{ line ->
sb.append(line);
}
backupService.restoreBackup(sb.toString()); // The result is not
committed to the database
}
setDefaultTarget(main)