...
Code Block | ||
---|---|---|
| ||
#!/bin/bash echo "Backup Script for Exporting Ontology from Graph Database Using enapso-graphdb-cli" # Set Variables DB_URL="http://localhost/fuseki" REPOSITORY_NAME="Test" FORMAT="application/x-trig" EXPORT_FILE="export.trig" REPORT_FILE="report.txt" TRIPLESTORE="fuseki" CONTEXT="http://ont.enapso.com/views" # Remove Previous Report File echo "Removing Previous Report File..." rm $REPORT_FILE # Export ontology enapsogdb export --dburl $DB_URL --repository $REPOSITORY_NAME --targetfile $EXPORT_FILE --context $CONTEXT --triplestore $TRIPLESTORE >> $REPORT_FILE 2>&1 echo "Backup made successfully" |
...
DB_URL
: URL where the triplestore is running.REPOSITORY_NAME
: Name of the repository.FORMAT
: Data format, For Fuseki, the data is only returned in theapplication/x-trig
format, so specifying the format is not necessary. For other triplestores like GraphDB and Stardog, the recommended format isapplication/x-trig
due to its support of named graphs.EXPORT_FILE
: Path and filename for the backup file.REPORT_FILE
: Path and filename for the report file, which contains the response from the script's execution.TRIPLESTORE
: Type of the triplestore (fuseki
,graphdb
,stardog
).CONTEXT
:Context
to be exported. If left empty, the entire repository is exported. If a string is provided, it saves the context's data. If an array of contexts is provided, it creates a zip file containing each context's data.
Context Exporting Details
Without Context:
For Fuseki: Exports the entire repository in
application/x-trig
format.For GraphDB and Stardog: Exports the whole repository in the specified format.
With Context as String:
For Fuseki: Exports the specified context in
text/turtle
format.For GraphDB and Stardog: Exports the specified context in the provided format.
With Context as Array:
For Fuseki: Exports each context in
text/turtle
format and saves them in a zip file.For GraphDB and Stardog: Exports each context in the provided format and saves them in a zip file with each file named its context.
Save the Script
Save the file with a
.sh
extension, such asbackup_script.sh
.
...