Page History
...
The Operation Script can be executed from a JS7 job to create database backups backup or to export the JOC Cockpit database at a regular basis.
Download
...
--classpath
- H2® ships from a single Java binary file, for example
h2-2.3.232.jar
. - The option specifies the path to the H2® Java binary file, by default the current directory is used:
./h2-2.3.232.jar
.
- H2® ships from a single Java binary file, for example
--url
- Specifies the location of the H2® database. The JS7 - Database using H2® is located with JOC Cockpit from the
<jetty-base>/resources/joc/h2
directory. The name of the database isjoc
. - The URL is prefixed with
jdbc:h2:
followed by the relative or absolute path to the database. If the prefix is omitted, it will be added by the script. - Examples:
jdbc:h2:/var/sos-berlin.com/js7/joc/resources/joc/h2/joc
/var/sos-berlin.com/js7/joc/resources/joc/h2/joc
- Specifies the location of the H2® database. The JS7 - Database using H2® is located with JOC Cockpit from the
--driver
- Specifies the class name of the H2® JDBC Driver, default:
org.h2.Driver
.
- Specifies the class name of the H2® JDBC Driver, default:
--user
- Specifies the account for the H2® database, default:
joc
.
- Specifies the account for the H2® database, default:
--password
- Specifies the password used for the account specified indicated with the
--user
option for the H2® database, default: no password. - Password input from the command line is considered insecure. Consider use of the
-p
switch offering a secure option for interactive keyboard input.
- Specifies the password used for the account specified indicated with the
--file
- When used with the
backup
andexport
command commands, specifies the path to the .zip archive file that holds the full database export. - When used with the
import
command, specifies the path to the .sql script file used for import. This offers to restore the database from a previous full export. - When used with the
shell
command, specifies the path to the .sql script file that holds SQL statements that should be executed.
- When used with the
--file-versions
- When used with the
backup
andexport
command commands, specifies the number of versions for which backup files will be stored
- When used with the
--sql
- When used with the
shell
command, specifies the SQL statement that should be executed. - Consider to apply quotes as with
--sql="SELECT COUNT(*) FROMM JOC_VARIABLES;"
. SQL statements should be terminated by semicolon.
- When used with the
--web-port
- When used with the
console
command, specifies the port used by the H2® Console, default:8082
.
- When used with the
...
-h | --help
- Displays usage.
-v | --verbose
- Displays verbose log output that includes invocation of the H2® Java binary.
-p | --password
- Asks the user for interactive keyboard input of the password used for the account specified with the
--user
option.. - The switch is used for secure interactive input as an alternative to use of the option
--password=<password>
.
- Asks the user for interactive keyboard input of the password used for the account specified with the
-z | --zip
- Creates/reads a compressed archive file when used with
export
andimport
commands.
- Creates/reads a compressed archive file when used with
Exit Codes
0:
operation successful1
: argument errors
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# export database to .zip archive file that holds the script.sql file
./operate-h2.sh export --url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc" --user=joc --file=/tmp/database-export.zip --zip
# export database to .sql text file with up to 3 versions
./operate-h2.sh export --url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc" --user=joc --file=/tmp/database-export.sql --file-versions=3
# export database from a docker container to a .zip archive stored on a volume
docker exec -ti js7-saas-2-7-2 /bin/bash \
/opt/sos-berlin.com/js7/script/operate-h2.sh export \
--classpath=/var/sos-berlin.com/js7/joc/lib/ext/joc/h2-2.3.232.jar \
--url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc;AUTO_SERVER=TRUE" \
--user=joc \
--file=/var/sos-berlin.com/js7/joc/resources/joc/database-export.zip \
--file-versions=3 --zip |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# backup database to .zip archive file that holds the database filefiles ./operate-h2.sh backup --url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc;AUTO_SERVER=TRUE" --user=joc --file=/tmp/database-backup.zip # backup database to .zip archive file with up to 3 versions ./operate-h2.sh backup --url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc;AUTO_SERVER=TRUE" --user=joc --file=/tmp/database-backup.zip --file-versions=3 # backup database from docker container to a directory mounted from a volume docker exec -ti js7-saas-2-7-2 /bin/bash \ /opt/sos-berlin.com/js7/script/operate-h2.sh backup \ --classpath=/var/sos-berlin.com/js7/joc/lib/ext/joc/h2-2.3.232.jar \ --url="/var/sos-berlin.com/js7/joc/resources/joc/h2/joc;AUTO_SERVER=TRUE" \ --user=joc \ --file=/var/sos-berlin.com/js7/joc/resources/joc/database-backup.zip \ --file-versions=3 |
...
Overview
Content Tools