Skip to content

Commit 974c4db

Browse files
authored
Merge pull request #144 from doubleSlashde/feature/export_script_linux
add export script for Linux for KeepTime1.2.0
2 parents 7f2aa6e + c0b30ea commit 974c4db

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
H2_VERSION=1.4.197
3+
DB_URL=jdbc:h2:file:./db/$H2_VERSION/keeptime-h2-db;DB_CLOSE_ON_EXIT=FALSE
4+
DB_USER=sa
5+
DB_PASSWD=
6+
SQL_BACKUP_FILENAME=KeepTime_database-export_H2-version-$H2_VERSION.sql
7+
8+
echo "Script to export the content of H2 databse from KeepTime version 1.2.0-SNAPSHOT to .sql file."
9+
echo "The script should be placed next to the .jar file."
10+
read -p "Press enter to continue"
11+
12+
echo -e "\nExtracting H2 driver from KeepTime .jar file."
13+
DRIVER_JAR_FROM_KEEPTIME=BOOT-INF/lib/h2-$H2_VERSION.jar
14+
jar xfv keeptime-1.2.0-SNAPSHOT.jar $DRIVER_JAR_FROM_KEEPTIME
15+
16+
echo -e "\nTriggering database backup."
17+
java -cp $DRIVER_JAR_FROM_KEEPTIME org.h2.tools.Script -url $DB_URL -user $DB_USER -script $SQL_BACKUP_FILENAME -options DROP
18+
19+
echo -e "\nCleanup of extracted .jar file."
20+
rm -rv BOOT-INF
21+
22+
echo -e "\nIf no error occured the export has succeeded."
23+
echo "The exported file was created at '$(pwd)/$SQL_BACKUP_FILENAME'."
24+
echo -e "\nYou can now import this file in a new version of KeepTime.\n"
25+
26+
read -p "All set. Press enter to exit script."

0 commit comments

Comments
 (0)