Database transfer guide
By following the steps outlined in this guide, you can safely and effectively transfer the AppSec Portal's database to a new host
This guide outlines the steps to transfer a database using Docker and various commands. The process involves creating a database dump, transferring it to a remote server, and restoring it in a new container. If you have changed the default values for DB_USERNAME and DB_NAME, make sure to use your custom values in the commands provided below. Otherwise, the values of postgres should be used for both.
Step 1: Preparing the New Host
Before transferring the database to the new host, ensure that the AppSec Portal is installed and properly set up on new host. Follow the steps below to prepare the new host for the database migration:
Ensure that the AppSec Portal configuration is correctly set up on the new host, including database connection parameters. If the DB_USERNAME and DB_NAME was changed during the setup, make sure to use the custom values in the configuration.
Drop the Existing Database Inside the container, execute the following command to drop the existing database:
Create a New Database. While still inside the container, create a new database with the same name using the following command:
Step 2: Create a Database Dump on the Current Host
Open a terminal or command prompt. Navigate to the directory where you want to create the database dump file.
Execute the following command to create a database dump from the current host:
The pg_dump file will be created in the previously specified directory.
Step 3: Transfer the Database Dump to the New Host
Copy the database dump file (pg_dump) to the new host using a secure method, such as SCP (Secure Copy) or any other file transfer mechanism you prefer.
Step 4: Restore the Database on the New Host
Once the database dump file is on the new host, open a terminal or command prompt on the new host. Navigate to the directory where the database dump file is located.
Copy the database dump file into the appsec-portal_postgres_1 container on the new host:
Restore the database from the dump on the new host inside the container:
Congratulations! You have successfully transferred the database.
You can also use this guide to restore the database from a backup by skipping steps 2 and 3.
Last updated