Migrating Data from Local PostgreSQL Database to an External PostgreSQL Database
The PAM360 application comes with PostgreSQL as its integrated backend database. Nonetheless, PAM360 also offers the functionality to migrate from the bundled local database to an external PostgreSQL database, thus enabling seamless data transfer. In this document, you will find a detailed explanation of the process involved in migrating your data between the local and external PostgreSQL databases.
Steps Required
Below are the steps to migrate data from the bundled PostgreSQL database to an external PostgreSQL database:
- Open the command prompt and navigate to the <PAM360_Installation_folder>\pgsql\bin directory.
- Create a dump file using the command - pg_dump dbname > pam360.sql. For example,
- In Windows - pg_dump.exe -U postgres -h 147.0.0.1 -p 2345 -W PassTrix > pam360.sql
- In Linux - ./pg_dump -U postgres -h 147.0.0.1 -p 2345 -W PassTrix > pam360.sql
- Create a database cluster in the PostgreSQL provided with the database owner's permission.
- Post the database creation, ensure that the extension 'pgcrypto' is available in the extension drop-down. If there is no such available extension, create it using the command - CREATE EXTENSION pgcrypto;
- Now, restore the dump file in the created database cluster using the following commands:
- For Windows - psql.exe -U admin -h 142.10.0.1 -p 5432 -d test -f pam360.sql
- For Linux - ./psql -U admin -h 142.10.0.1 -p 5432 -d test -f pam360.sql
- Execute the following commands:
- update task_input set admin_status = 4 where schedule_id in (select schedule_id from schedule where schedule_name like 'FWBackupSchedule');
- update DEFAULT_TASK_INPUT set variable_value = 'dump' where variable_name like 'backup.content.type';
- Now, make a copy of the below files under
<PAM360_Installation_folder>\conf directory and rename them:
- customer-config.xml to customer-config_old.xml.
- database_params.conf to database_params_old.conf.
- Open the database_param.conf file and do the steps that follow:
- Replace localhost with the hostname of the PostgreSQL server running in an external database.
- Change the port number to the actual port number of the PostgreSQL instance in an external database.
- Set SSL=true, and provide the user details that were used to restore the dump file to the database.
- Update the db.password.encrypted to false.
- Now, save and close the file database_param.conf.
Notes: The password given here will be in plain text at that instance and will be encrypted from the next consequent occurrence.
- Open customer-config.xml and search for startdbserver= true and change its value to false.
- Download the PostgreSQL root CA certificate. If you are unaware of creating an SSL for the PostgreSQL database, refer to this section to generate the required SSL certificates and validate the SSL connection.
- Import the root CA certificate into PAM360.
- Navigate to <PostgreSQL_Installation_folder>pgsql_installation\data and open the file pg_hba.conf:
- Add an entry at the end with the IP address of the machine/server on which the PAM360 is running.
E.g., host all <user name> <ip address>/32 md5
Notes: The above step applies only to users who use an external PostgreSQL enterprise database as their backend database. For users with cloud-based databases, the process will be performed in an automated process.
- Add an entry at the end with the IP address of the machine/server on which the PAM360 is running.
- Navigate to <PostgreSQL_Installation_folder>pgsql_installation\data
and open the file postgresql.conf:
- Search for listen_addresses and provide the IP address of the server where PAM360 is running.
- Restart the PostgreSQL server.
- Start the PAM360 service.
Now you have successfully migrated your data from the local PostgreSQL database to the external PostgreSQL database.