See below to back up and restore an EDB PostgreSQL database on the same virtual machine.
To restore your EDB PostgreSQL database on a different virtual machine, we recommend using the scripted version.
Requirements to restore an EDB PostgreSQL database
You must have the following:
Access to the VM as the enterprisedb user.
PostgreSQL EDB (version 16) installed at:
/usr/lib/edb-as/16/Encryption keys configured and accessible via the database vault.
Logging into the virtual machine
Run the following commands to log into the virtual machine with the <vm-ip> hostname or IP address.
ssh root@<vm-ip>su - enterprisedbStarting EDB PostgreSQL
Run the following command to start the EDB PostgreSQL database.
/usr/lib/edb-as/16/bin/pg_ctl start -D /var/lib/edb-as/16/mainCreating a database in EDB PostgreSQL
Create a database and a table. For example:
psql -U enterprisedbCREATE DATABASE mydb;\c mydbCREATE TABLE test_table (id INT, name TEXT);INSERT INTO test_table VALUES (1, 'Alice'), (2, 'Bob');In this example:
mydbis the specific database nametest_tableis the specific table name
Verifying the database name
Run the following command to verify the database name.
psql -U enterprisedb -lBacking up the EDB PostgreSQL database
Generate an encrypted backup of the EDB PostgreSQL database
pg_dumpall -U enterprisedb -f <backup>.sqlWhere <backup>.sql is the backup file name.
Restarting the EDB PostgreSQL database
Restart the database if needed:
/usr/lib/edb-as/16/bin/pg_ctl restart -D /var/lib/edb-as/16/mainRestoring the EDB PostgreSQL backup
Run the following command to restore the backup:
psql -U enterprisedb -d mydb -f <backup>.sqlWhere <backup>.sql is the name of the backup file.