Migration of the database data can be done using the following two methods:
Both of the steps are applicable if the both the databases are running inside the MedStack cluster or outside of MedStack.
Via MedStack Control – Recommended
Using the container shell feature, you can use an existing service with a CLI utility deployed in a cluster to send commands to the database server.
Steps:
Note: You can grab the SSL Certificate for the connection string here for PostgreSQL db or MySQL db.
- Shell into the container where database client CLI is installed.
- Grab the connection strings for the Old database that you would like to migrate the data from.
- Use a mysqldump or pg_dump CLI tool to create a backup of the database.
Note: It is recommended that you backup the database directly onto a Volume in order to make sure that the backups persist in case of a container restart. - Grab the connection strings for the New database server.
- Use mysql or pg_restore CLI tool to restore the backup on to the new Database
- Connect to the new database from the container using the CLI.
- Verify the data has been restored successfully.
- Delete the backup from container or the Volume.
Note: if the backup is inside a Volume and it isn't cleaned up after a successful restore, you may see an increase in storage cost from Volume backup.
Via Endpoint with Allowed IP
An endpoint in this example could represent a local dev machine, workstation, static server, etc. which has an IP address that's allowed to connect to the database server in the cluster.
Steps:
Note: You can grab the SSL Certificate for the connection string here for PostgreSQL db or MySQL db.- Add your public IP address to the Allowed IP list on both Old and New Database server.
- Grab the connection strings for the Old database that you would like to migrate the data from.
- Connect to the Old database from your local machine.
Note: You can use Postgres CLI or PgAdmin for connecting to PostgreSQL DB Server. Similarly you can use MySQL CLI or MySQL Workbench to connect with MySQL DB Server. - Backup the database to your local machine.
- Grab the connection strings for the New database server.
- Connect to the New database server from you local machine.
- Restore the database backup to the new Database server.
- Verify the data has been restored successfully.
- Delete the backup from your local machine.
After the backup is restored, monitor the new Database server for any missing data or for stability. Once you are comfortable with the new database server, delete the Old database server from MedStack.