Backup / Restore Data

In this procedure you need to setup 2 environment variables:

# Folder where you want to backup your data (could be a nfs mount point)
export BACKUP_FOLDER=...
# Folder where you extracted the ltu-engine-installation archive.
export INSTALL_FOLDER=...

1.1. Optional step

If you want to ensure your data is fully synchronized between the old and the new server, you need to stop the image addition during the migration.
To do that, run:

su - ltu
ltud stop processor

1.2. Required steps

su - ltu
mkdir -p $BACKUP_FOLDER/data/ltu
cp -r /opt/ltuengine/data/ltu/query $BACKUP_FOLDER/data/ltu
cp -r /opt/ltuengine/data/ltu/reports $BACKUP_FOLDER/data/ltu
cp -r /opt/ltuengine/data/ltu/storage $BACKUP_FOLDER/data/ltu
cp -r /opt/ltuengine/config $BACKUP_FOLDER
pg_dumpall -p 7791 > $BACKUP_FOLDER/engine.dump
chown -R ltu $BACKUP_FOLDER

1.3. Optional step

If you run the optional step on the origin server, you may want to restart the stopped services:

su - ltu
ltud start processor

2.1. On a new server

To restore a backup on a new server, you have to make sure the Engine version is exactly the same as the one on the server the backup was created on.

2.1.1. Install the product with the configuration as root:

cd $INSTALL_FOLDER
cp $BACKUP_FOLDER/config/*.lic ./
./install.sh -i $BACKUP_FOLDER/config/ltuengine.spec

If you make the install without using the old config file, please make sure that the passwords listed in the file ./opt/ltuengine/ltuengine.spec are the same.

To restore the old config file:
# copy the old config file
cp $BACKUP_FOLDER/config/ ./

# regenerate all the config files
ltusaas-generate-config-files -i config/ltuengine.spec -o run/cache/config/

2.1.2. After the installation, stop the product and restore old data :

su - ltu
ltud stop all
ltud start database
 
# export some environment variables
export PGPASSWORD=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_PASSWORD"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_USER=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_USER"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_PORT=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_PORT"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
 
# drop previous databases if any
dropdb -p "${DB_PORT}" -U "${DB_USER}" saas_si
dropdb -p "${DB_PORT}" -U "${DB_USER}" saas_log
 
# restore data
cp -r $BACKUP_FOLDER/data/ltu /opt/ltuengine/data
psql -p "${DB_PORT}" postgres -f $BACKUP_FOLDER/engine.dump
 
# cleanup environment variables
unset PGPASSWORD
unset DB_USER
unset DB_PORT

2.1.3. Update the database if hostname is different

If the new server has a different hostname than the old one, the database needs to be updated (the following is only for single server setup. For multi-servers setup please contact the support):

export OLD_HOSTNAME=PUT_YOUR_OLD_HOSTNAME_HERE
 
# declare the psql password so you to do not have the type it
export PGPASSWORD=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_PASSWORD"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_USER=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_USER"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_PORT=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_PORT"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
 
# update the list of all hosts by replacing old server name by current server hostname
psql -p "${DB_PORT}" -U "${DB_USER}" saas_si -c "update hw_server set hostname='$(hostname)' where hostname='${OLD_HOSTNAME}';"
 
# update the list of all applications by replacing old server name by current server hostname
psql -p "${DB_PORT}" -U "${DB_USER}" saas_si -c "update application_property set value='$(hostname)' where name='database_hostname';"
 
# cleanup environment variables
unset PGPASSWORD
unset DB_USER
unset DB_PORT
 
# regenerate all the config files
ltusaas-generate-config-files -i config/ltuengine.spec -o run/cache/config/

2.1.4. To finish, restart all the LTU Engine services

# start LTU Engine services
ltud start all

2.2. On the same server

To restore a backup on the same server, you have to follow these instructions:

2.2.1. Stop the product and restore old data :

su - ltu
ltud stop all
ltud start database
 
# export some environment variables
export PGPASSWORD=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_PASSWORD"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_USER=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_ROOT_USER"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
export DB_PORT=$(cat /opt/ltuengine/run/cache/config/ltuengine.full.spec | grep '"DB_PORT"' | cut -d':' -f2 | sed -r 's/[\", ]//g')
 
# drop previous databases if any
dropdb -p "${DB_PORT}" -U "${DB_USER}" saas_si
dropdb -p "${DB_PORT}" -U "${DB_USER}" saas_log
 
# restore data
cp -r $BACKUP_FOLDER/data/ltu /opt/ltuengine/data
psql -p "${DB_PORT}" postgres -f $BACKUP_FOLDER/engine.dump
 
# cleanup environment variables
unset PGPASSWORD
unset DB_USER
unset DB_PORT

2.2.2. To finish, restart all the LTU Engine services

# start LTU Engine services
ltud start all

Now you need to rebuild your application to recreate the kimas.
To do that go to your frontoffice http://SERVER_IP:8888 and rebuild your application in the application section.

Make sure your new server IP is in the IP whitelist. See Configuring Front Office.