...
Open a command prompt or terminal.
Run the command
node -v
and press Enter. This will display the version of Node.js if it is installed.Run the command
npm -v
and press Enter. This will display the version of npm if it is installed.
For using the ENAPSO tools, it's important to have at least Node.js version 10 or higher, as earlier versions might not support some functionalities of the tools.
If you need to update Node.js to the latest version, you can download it from the official Node.js website and install it on your system. It will automatically replace the older version with the new one.
Installation
Install the enapso-graphdb-cli tool globally using npm:
...
Use the following script to create a backup of the graph database repository. This The below script example is configured for a Fuseki repository but can be adjusted for other supported triplestores by changing the appropriate variables. Below, you'll find detailed command line examples for each triplestore, ensuring you can tailor the backup process to your specific setup.
Command Line Examples for Different Triplestores
Fuseki Example
In Fuseki, the data is returned in application/x-trig
format when extracting the repository because we cannot set the format of the data.
Code Block |
---|
enapsogdb export --dburl "http://localhost/fuseki" --repository "Test" --targetfile "fuseki_backup.trig" --triplestore "fuseki" |
GraphDB Example
Code Block |
---|
enapsogdb export --dburl "http://localhost/graphdb" --repository "Test" --targetfile "graphdb_backup.trig" -- |
...
format "application/x-trig" --triplestore "graphdb" |
Stardog Example
Code Block |
---|
enapsogdb export --dburl "http://localhost/stardog" --repository "Test" --targetfile "stardog_backup.trig" -- |
...
format "application/x-trig" --triplestore "stardog" |
Create a New Script File
Open a text editor such as Notepad++, or Visual Studio Code.
Copy and paste the script content below.
...
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
.
...
This setup allows you to create consistent and reliable backups of your graph database repositories across different operating systems and triplestore configurations.
Restore Process
The following below script example restores a graph database repository from a backup file. It includes an optional step to rebuild the cache on the ENAPSO platform, beneficial necessary for those using the ENAPSO together or ENAPSO together Free services, which utilize a cache mechanism to enhance data management efficiency and speed. Below, you'll find detailed command line examples for each triplestore, ensuring you can tailor the restore process to your specific setup.
...
Fuseki Example
Code Block enapsogdb import --dburl "http://localhost/fuseki" --repository "Test" --sourcefile "fuseki_backup.trig" --FORMATformat "application/x-trig" --triplestore "fuseki"
GraphDB Example
Code Block enapsogdb import --dburl "http://localhost/graphdb" --repository "Test" --sourcefile "graphdb_backup.trig" --FORMATformat "application/x-trig" --triplestore "graphdb"
Stardog Example
Code Block enapsogdb import --dburl "http://localhost/stardog" --repository "Test" --sourcefile "stardog_backup.trig" --FORMATformat "application/x-trig" --triplestore "stardog"
...
Code Block |
---|
curl -X POST http://localhost/enapso-dev/graphdb-management/v1/build-cache >> Report/EnapsoTestReport.txt$REPORT_FILE |
This command triggers the ENAPSO service to rebuild its cache using the latest uploaded data. This step ensures that any changes from the restoration process are promptly reflected, enhancing the performance and efficiency of queries against the updated repository.
Include this step if you use the ENAPSO platform to benefit from the cache mechanism to enhance data management efficiency and speed.This enhanced documentation provides clear instructions and additional context for using the enapso-graphdb-cli
tool effectively, ensuring users can manage their graph databases with confidencebecause it is necessary for the cache mechanism. When you upload data, you need to create a cache because the information about the class model for auto-generating templates or managing templates is retrieved from the cache, not directly from the graph database repository. If you do not create a cache and upload the ontology, and there is a class for which you want to create an auto CRUD template, you will be unable to create it and got an error message because the cache will not have information about that class.
Conclusion
Regular backups and effective restoration capabilities are essential for managing graph database repositories securely. Using the enapso-graphdb-cli
tool, users can easily safeguard their data and restore it quickly if necessary. It's important to maintain a consistent backup routine and periodically test your restoration process to ensure data integrity and minimize downtime.
...