Skip to main content

How to backup PostgreSQL databases on Linux CLI?

Article ID

20002

Description

Please use the following steps to backup PostgreSQL databases using AhsayOBM on Linux CLI.

Create backup set

  1. Login to your OBM user account via the AhsayCBS web management console.
  2. Go to User.
  3. Open Backup Sets.
  4. Click the [+] sign to create a new backup set.
  5. To proceed, check the names of the databases you aim to backup firs. To do this, login as root to the PostgreSQL database server using an SSH client.
  6. Connect to the PostgreSQL database server by using the following command: psql -h localhost -U postgres
  7. Show the list of databases: \l
  8. Ater confirming the databases, go back to your AhsayCBS web management console.
  9. Change the backup set type to PostgreSQL Backup.
  10. Rename the file backup set.
  11. Select Linux for platform.
  12. Enter the login ID and password, followed by the host of the machine used.
  13. You may keep the Port value on default or change it accordingly if your PostgreSQL database instance is setup using a different port.
  14. Enter the path for pg_dump. If PostgreSQL database instance is running on a remote server or cloud service, make sure that the PostgreSQL version matches the version installed on the backup machine you're using.
  15. Click Next.
  16. Under Other selected source, click the [+] button to add a backup source.
    • Enter the value PostgreSQL as is if you intend to select ALL databases from your PostgreSQL instance.
    • Manually enter the directory path of each database proceeded with postgreSQL/ to select specific database.
  17. Repeat the same step if you intend to add other sources as well.
  18. Click Next to continue.
  19. Enter the host name to use the computer name for the scheduler.
  20. You may use the default schedule provided or create a new one.
  21. Click Next.
  22. Click the [+] button to add a new storage destination and select AhsayCBS.
  23. Click the [+] button again.
  24. Leave the backup mode on Sequential.
  25. Click Save.

Configure the settings before running backup job

  1. Open File Viewer.
  2. Beside your backup set name, click on the hyperlinked text, "File Viewer is disabled. Click to enable.
  3. You will be redirected to the Others section of the settings. Check and configure the Temporary Directory accordingly.
  4. Leave Compressions on default. Encryption key will be set up on Linux CLI.
  5. Scroll down and enable File Viewer.
  6. Click Save.

Set up the encryption key

  1. Login as root to the Linux backup machine using an SSH client.
  2. Use the cd command to go to bin: cd /usr/local/obm/bin
  3. Open AhsayOBM to setup the encryption key: sh RunConfigurator.sh
  4. Enter 1 to login.
  5. Enter the backup server URL, port, and protocol. For Proxy, we'll enter "N".
  6. Enter the login name and password.
  7. Enter Y to setup the encryption key of your backup set.
  8. Enter Y again to confirm.
  9. Enter 1 to select Default.
  10. Enter 8 to quit
  11. .

Run the backup job

  1. Use the sh command to run the backup job: sh RunBackupSet.sh '[backup set name]'
  2. After the backup job, a line will indicate Backup Completed Successfully.

Check the backed up databases from File Viewer

  1. Open File Viewer and reload the page.
  2. Select the backup set.
  3. Click on the PostgreSQL folder to see all the databases backed up.