How to change the backup storage location in PEM

Arti Harer
Arti Harer

Authors: Arti Harer and William Ivanski.

PEM can take backups of the database, but sometimes it's required to change the backup target location, for example to point to a different storage drive. This article shows the steps on how to accomplish that.

Default target backup location

When we take a backup using the below process in PEM, then by default the backup is stored under the /var/lib/pemhome/.pem/storage/pga_user_10/ folder.

How to take a backup in PEM

Right click on server, click on Backupserver/Backup Global, click on Provide backup options

Note how the backup is stored in the default backup location:

# ls -lrth /var/lib/pemhome/.pem/storage/pga_user_10/
total 16M
-rw-r--r--. 1 pem daemon 9.2M Oct  8 05:00 server_backup

How to change the target backup location

1. Copy the contents of config.py to config_local.py

# cd /usr/edb/pem/web/  
# cp config.py config_local.py 

The config_local.py file is not present by default. You need to create config_local.py alongside config.py. Then put any customized settings in config_local.py file. Don't ever edit config.py, as it may be overwritten by upgrades.

2. Create a new target backup directory

# mkdir /var/lib/edb/backup/
# chown enterprisedb:enterprisedb /var/lib/edb/backup/

3. Edit the config_local.py

# vi /usr/edb/pem/web/config_local.py

STORAGE_DIR= "/var/lib/edb/backup/"

4. Restart the pemagent and httpd service

This is needed so the changes take effect:

# systemctl restart pemagent.service  
# systemctl restart httpd.service 

5. Take a new backup

Take a new backup following the procedure above. The new backup will be stored under the new target backup location, which we configured to be /var/lib/edb/backup/:

$ ls -lrth /var/lib/edb/backup/pga_user_10/
total 2328
-rw-r--r--. 1 pem daemon  Oct  11 01:55 backup_new

Troubleshooting

After following the above process, you might face below error while logging into PEM URL:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Snippet from error logs:

[Mon Oct 11 06:09:42.303858 2022] [wsgi:error] [pid 67895] [remote 127.0.0.1:51986]   File "/usr/edb/pem/web/pgadmin/utils/paths.py", line 89, in init_app
[Mon Oct 11 06:09:42.303861 2022] [wsgi:error] [pid 67895] [remote 127.0.0.1:51986]     'The user does not have permission to read and write to the '
[Mon Oct 11 06:09:42.303875 2022] [wsgi:error] [pid 67895] [remote 127.0.0.1:51986] werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The user does not have permission to read and write to the specified storage directory.

To resolve this error needs to provide read, write and execute permissions to the specified new storage directory:

# ls -ld /var/
drwxrwxrwx. 22 root root 4096 Jul 13 06:27 /var/

# ls -ld /var/lib/
drwxrwxrwx. 61 root root 4096 Oct  11 07:03 /var/lib/

# ls -ld /var/lib/edb/
drwxrwxrwx. 9 enterprisedb enterprisedb 220 Oct  11 07:03 /var/lib/edb/

# ls -ld /var/lib/edb/backup/
drwxrwxrwx. 2 enterprisedb enterprisedb 6 Oct  11 07:03 /var/lib/edb/backup/

Then take a new backup again.

Was this article helpful?

0 out of 0 found this helpful