Before attempting to create a backup of your database, you should be aware that certain information is encrypted in the database using a key. The key is stored /etc/raas/pki/.raas.key. This file will need to also be saved along with your database backup in order to access this encrypted data.
Also, as part of the database restore process, the database will get dropped, or deleted. If there are any users or applications accessing the database when you attempt to do this the operation will fail. Please make sure that the RaaS daemon is stopped and that no other users are accessing the database before attempting to drop the database.
VMware Aria Automation Config 8.12.x
Users of SaltStack Enterprise are encouraged to create backups of their database on a regular basis in case things go wrong and data needs to be restored.
There are multiple methods for creating a backup, but here we will just provide how to do this from the command line.
Connect to your database server and become the postgres user
root@raasdb:/# su - postgres postgres@raasdb:~$
List the databases to find the correct name of your SaltStack Enterprise database. The name should be similar to raas_43cab1f4de604ab185b51d883c5c5d09.
postgres@raasdb:~$ psql --list | grep -i raas raas_43cab1f4de604ab185b51d883c5c5d09 | salt_eapi | UTF8 | en_US.utf8 | en_US.utf8 |
Using the complete name of the database we can now create a compressed backup of the database using the following command.
NOTE: This command will create a compressed copy of your database in the current working directory. Be sure you have enough space.
postgres@raasdb:~$ pg_dump raas_43cab1f4de604ab185b51d883c5c5d09 | gzip > raas_43cab1f4de604ab185b51d883c5c5d09.`date +%Y%m%d`.gz
Restoring your database may be a lengthy process depending on the size of the database backup file.
You will first need to create the database to import the data to.
postgres@raasdb:~$ psql -c "create database raas_43cab1f4de604ab185b51d883c5c5d09";
With the database created you will then need to import backup data.
postgres@raasdb:~$ gunzip -c raas_43cab1f4de604ab185b51d883c5c5d09.20200519.gz | psql raas_43cab1f4de604ab185b51d883c5c5d09
With the data restored you can now reconnect your RaaS server to the database.