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 - enterprisedb

Starting 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/main

Creating a database in EDB PostgreSQL

Create a database and a table. For example:

psql -U enterprisedb
CREATE DATABASE mydb;
\c mydb
CREATE TABLE test_table (id INT, name TEXT);
INSERT INTO test_table VALUES (1, 'Alice'), (2, 'Bob');

In this example:

  • mydb is the specific database name
  • test_table is the specific table name

Verifying the database name

Run the following command to verify the database name.

psql -U enterprisedb -l

Backing up the EDB PostgreSQL database

Generate an encrypted backup of the EDB PostgreSQL database

pg_dumpall -U enterprisedb -f <backup>.sql

Where <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/main

Restoring the EDB PostgreSQL backup

Run the following command to restore the backup: 

psql -U enterprisedb -d mydb -f <backup>.sql

Where <backup>.sql is the name of the backup file.