Preparing for Update¶
Note
Before starting the backup export the data model and stop the Tomcat server
Components Backup¶
Database Backup¶
Database backup is done with standard DBMS tools (pg_dump, pg_restore, pg admin, etc.). An example of creating a backup copy using the pg_dump utility:
Stop the Tomcat server:
systemctl stop tomcat
Specify the database name in the <TOMCAT_HOME>/conf/Catalina/localhost/universe-backend.xml configuration file. The name is contained in a line of the form (in the example the "universe" name is specified):
Resource .... url="jdbc:postgresql://localhost:5432/universe" .../>
Run the command:
pg_dump -U ${POSTGRES_USERNAME} -h ${POSTGRES_ADDRESS} -Fc ${DATABASE_NAME} > ./${DATABASE_NAME}$(date +%F_%H%M).dump
You can find out the path to the database in the file
./bin/setenv.sh
or with the command:echo $POSTGRES_ADDRESS$DATABASE_NAME
Start the Tomcat server:
systemctl start tomcat
Command parameters may vary. You must make sure that all universe database schemas have been included in the backup.
Search Index Backup¶
Backing up the search index is done using standard Opensearch tools. See the official documentation (same for Opensearch) for details. Before performing the operation you should change Opensearch settings according to your target system's configuration.
To back up the search index:
Specify the path to the snapshot repository in the Paths section (of file <OPENSEARCH_HOME>/config/opensearch.yml). The path must be available to all nodes in the cluster:
path.repo : /mount/backups
Restart Opensearch. Command example:
systemctl restart opensearch
Create a directory for the repository:
mkdir -p /mount/backups
Navigate to the created directory:
cd /mount/.
Assign write permissions to all users:
chmod a+w ./backups
Restart the cluster nodes, if a cluster configuration is used (otherwise, you can skip this step).
Add the repository to the cluster configuration. Execution example from the console using the curl utility:
$ curl -XPUT 'localhost:9200/_snapshot/universe_indices_backup' -d '{ "type" : "fs", "settings" : { "compress" : true, "location": "<path to repository directory from settings>/universe_indices_backup" } }'
If the path to the repository directory was specified in path.repo, it does not need to be included in the above command. In that case, the command would look like this:
curl -XPUT 'localhost:9200/_snapshot/universe_indices_backup' -d '{ "type" : "fs", "settings" : { "compress" : true, "location" : "universe_indices_backup" }}'
Check if the previous step was successful (the command should show the current repository settings):
$ curl -XGET 'localhost:9200/_snapshot/universe_indices_backup'
Create a snapshot of all active cluster indexes (the name snapshot_1 is used in the example):
$ curl -XPUT 'localhost:9200/_snapshot/universe_indices_backup/snapshot_1?wait_for_completion=true'
If the snapshot is successfully created, the message of the form state: "SUCCESS"
will be displayed.
For more information on snapshot state, run the following command:
$ curl -XGET 'localhost:9200/_snapshot/universe_indices_backup/snapshot_1'
Backup of Configuration Files¶
Copy the contents:
<TOMCAT_HOME>/webapps directories;
The <TOMCAT_HOME>/universe-integration directory;
The directory specified in the -Dunidata.conf parameter of the tomcat.conf configuration file.
Note
By default, the -Dunidata.conf parameter is located in the <TOMCAT_HOME>/conf/tomcat.conf file
Specify the path to the logback.xml file in <TOMCAT_HOME>/conf/tomcat.conf:
Dlogback.configurationFile=/opt/universe/universe.conf/logback.xml in $TOMCAT_HOME/conf/tomcat.conf
If the universe-backend.xml file located in <TOMCAT_HOME>/ conf/Catalina/localhost has been modified, back it up for later update.
Restoring Backups¶
Restoring Database Backup¶
Database backup can be restored using standard DBMS tools (pg_restore, pg admin, etc.). The following is an example of restoring the backup copy using pg_restore.
Stop the Tomcat server:
systemctl stop tomcat
Create an empty database. To do this use the console commands:
su postgres psql -U postgres create database <base name>; \q
Or use the SQL query:
CREATE DATABASE <base name> WITH OWNER = postgres
Alternatively, you can clean up the existing database.
Run the command:
$ pg_restore -d universe -p 5432 -h localhost -U <username> -- jobs=<number of concurrent threads, each occupying one connection + 1 administrative connection> <path and filename>
Start the Tomcat server:
systemctl start tomcat
Restoring Opensearch Index Backup¶
Search index backups can be restored using standard Opensearch tools. See the official documentation (same for Opensearch) for details.
To restore a search index backup:
Close the current indexes:
$ curl -XPOST 'localhost:9200/_all/_close'
The number of index parts (Shards) in the snapshot and in the cluster must match, otherwise the recovery will fail. The requirement does not apply to empty clusters.
In case the name of the current snapshots is unknown, use the command:
$ curl -XGET 'localhost:9200/_snapshot/_all'
Restore the snapshot. Example command for a snapshot named snapshot_1:
$ curl -XPOST 'localhost:9200/_snapshot/universe_indices_backup/snapshot_1/_restore'
This is a snapshot of the search index state. There can be several such snapshots to store several Opensearch states.