Skip to content

Instantly share code, notes, and snippets.

@fgrilli
Last active December 28, 2022 08:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fgrilli/800c3ad08300e030e6aa09f5d8980810 to your computer and use it in GitHub Desktop.
#!/bin/bash
# h2-1.4.200.jar and h2-2.1.214.jar files must be present in the current working directory.
# They can be found respectively in 6.2.26 and 6.2.27 Magnolia webapps
path=/path/to/webapps/magnoliaAuthor/repositories/magnolia #repeat on public
for filepath in $(find $path -name '*.mv.db'); do
parentdir="$(dirname "$filepath")"
# Export data from old db file to backup.zip
echo "Exporting database $parentdir/db..."
java -cp h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:$parentdir/db -script $parentdir/backup.zip -options compression zip
rm -f $parentdir/db.mv.db
# Import data from the backup.zip to the new db file
echo "Importing data..."
java -cp h2-2.1.214.jar org.h2.tools.RunScript -url jdbc:h2:$parentdir/db -script $parentdir/backup.zip -options compression zip variable_binary
rm -f $parentdir/backup.zip
echo "$parentdir/db migrated succesfully"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment