Migrating Apps
Goal
A safe migration of an existing app to a new app, while still having the old app available. So if something goes wrong, you haven’t lost the old app.
Create new app with a different name
In this guide, I’ll be using the app vaultwarden
as an example. I chose the name testwarden
for the new app install.
I installed the new app with mostly default settings, just changed service type to ClusterIP
and setup a new, temporary, ingress.
Scale down both apps
We need to run the following commands in the host shell. Everything between <>
needs to be replaced with the actual value.
First, we need to get the names of the deploys.
Example:
Here we find the names of the deploys we want to scale down. For apps installed with the default name, it will just be that name.
For apps installed with a different name, it will be <app-name>-<default-name>
.
So for vaultwarden
(the default name), it will be vaultwarden
. But for the vaultwarden app that was installed with the name testwarden
, it will be testwarden-vaultwarden
.
Postgresql databases
If the app uses a Postgresql database, we need to make a backup and restore that backup to the new app’s database. To access the database, the app must be running.
Configure database connections in pgAdmin
run the tcdbinfo.sh script to see the connection details for both the old and the new database, and set them up in pgAdmin.
Create database Backup
In pgAdmin
, right click vaultwarden->Databases->vaultwarden
and click Backup...
. Give the file a name (e.g. vaultwarden.sql
) and click Backup
.
Restore database backup
In pgAdmin
, right click testwarden->Databases->vaultwarden
and click Restore...
. Select the sql file (vaultwarden.sql
).
On the 2nd tab page, select the first 3 options (Pre-data
, Data
and Post-data
). On the last tab, select Clean before restore
. Now click Restore
.
MariaDB Databases
MariaDB Database Migration
If the app uses a MariaDB database, we need to make a backup and restore that backup to the new app's database.
Configure database connections in adminer
To get the MariaDB credentials from each install the easiest way (until a script does this) is logging into the main container shell and typing env
, which pulls down the list of environment variables
used by the container, including the database credentials
.
Repeat the same for the “new” app
Create database Backup
Login to adminer
using the 4 values highlighted in red above. For most users it’ll be appname-mariadb.ix-appname.svc.cluster.local:3306
or in this case photoprism-mariadb.ix-photoprism.svc.cluster.local:3306
Click Export
, choose a compression output (gzip) and press export
Restore database backup
Now you login to adminer
with the “new” app
Click Import
, then Choose Files
, upload your backup and then click Execute
Migrate the PVCs
Get the PVCs names and paths
The following commands will return the PVCs for the old and the new install.
Take note of all the PVCs that do not contain postgres
, redis
or cnpg
. vaultwarden
only has 1 data PVC. There are apps that have more than 1. You’ll want to migrate them all.
Now, find the full paths to all these PVCs.
If this returns a very long list, you can add | grep <app-name>
to filter for only the PVCs of the app you’re currently working on.
A full PVC path looks something like this: poolname/ix-applications/releases/app-name/volumes/pvc-32341f93-0647-4bf9-aab1-e09b3ebbd2b3
.
Destroy new PVC and copy over old PVC
Destroy the PVCs of the new app and replicate the PVC of the old app to the new location.
The new-pvc
will look something like poolname/ix-applications/releases/testwarden/volumes/pvc-32341f93-0647-4bf9-aab1-e09b3ebbd2b3
.
The old-pvc
will look something like poolname/ix-applications/releases/vaultwarden/volumes/pvc-40275e0e-5f99-4052-96f1-63e26be01236
.
Example of all commands in one go:
Scale up both apps
Use the same commands from the scaling down step, but replace the 0 with a 1.
Conclusion
You should now be able to log in on the new install.