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
- Login to your OBM user account via the AhsayCBS web management console.
- Go to User.
- Open Backup Sets.
- Click the [+] sign to create a new backup set.
- 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.
- Connect to the PostgreSQL database server by using the following command: psql -h localhost -U postgres
- Show the list of databases: \l
- Ater confirming the databases, go back to your AhsayCBS web management console.
- Change the backup set type to PostgreSQL Backup.
- Rename the file backup set.
- Select Linux for platform.
- Enter the login ID and password, followed by the host of the machine used.
- You may keep the Port value on default or change it accordingly if your PostgreSQL database instance is setup using a different port.
- 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.
- Click Next.
- 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.
- Repeat the same step if you intend to add other sources as well.
- Click Next to continue.
- Enter the host name to use the computer name for the scheduler.
- You may use the default schedule provided or create a new one.
- Click Next.
- Click the [+] button to add a new storage destination and select AhsayCBS.
- Click the [+] button again.
- Leave the backup mode on Sequential.
- Click Save.
Configure the settings before running backup job
- Open File Viewer.
- Beside your backup set name, click on the hyperlinked text, "File Viewer is disabled. Click to enable.
- You will be redirected to the Others section of the settings. Check and configure the Temporary Directory accordingly.
- Leave Compressions on default. Encryption key will be set up on Linux CLI.
- Scroll down and enable File Viewer.
- Click Save.
Set up the encryption key
- Login as root to the Linux backup machine using an SSH client.
- Use the cd command to go to bin: cd /usr/local/obm/bin
- Open AhsayOBM to setup the encryption key: sh RunConfigurator.sh
- Enter 1 to login.
- Enter the backup server URL, port, and protocol. For Proxy, we'll enter "N".
- Enter the login name and password.
- Enter Y to setup the encryption key of your backup set.
- Enter Y again to confirm.
- Enter 1 to select Default.
- Enter 8 to quit .
Run the backup job
- Use the sh command to run the backup job: sh RunBackupSet.sh '[backup set name]'
- After the backup job, a line will indicate Backup Completed Successfully.
Check the backed up databases from File Viewer
- Open File Viewer and reload the page.
- Select the backup set.
- Click on the PostgreSQL folder to see all the databases backed up.