How to Migrate Postgres on Unraid

I just upgraded my Immich container which now requires Postgres14 or later. I was previously using 13 for Immich and Divinci Resolve and I needed to migrate my databases. I didn't find it very intuitive and thought I'd record the process so that maybe it would help someone else out there.

How to Migrate Postgres on Unraid
YouTube

I just upgraded my Immich container which now requires Postgres14 or later. I was previously using 13 for Immich and Divinci Resolve and I needed to migrate my databases.

I didn't find it very intuitive and thought I'd record the process so that maybe it would help someone else out there. This isn't strictly limited to Unraid but the file paths and mappings are Unraid specific. You can likely adapt it to however you're hosting Docker with the same commands but be aware of where you are saving it.

I found this method as a way to create a .dump file from a database, save it, move it from one folder to another, then restore it to a different docker container as a database.

Disclaimer: I am not a SQL wizard. Please don't ask me specifics about the postgres db.

Assumptions:

I use Adminer (also on Community Apps on Unraid) to verify and create tables.

I have two docker containers ready that are trying to access the same port. Thus, I will need to stop one before I start the next.

You know your Database connection info and names.

You know where your database files are stored.

Commands:

You'll need to replace components with your Postgres Username, IP address, port, filepath and database name.

pg_dump -U DBUSERNAME -h IPADDRESS -p PORT -fc -f /var/lib/postgresql/data/immich.dump DBNAME

pg_restore -U DBUSERNAME -h IPADDRESS -p PORT -d DBNAME /var/lib/postgresql/data/immich.dump

Privacy Policy
Terms and Conditions