Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Restoring Immich From Backup

Featured Replies

Hello!

I am running UnRaid 7.1.3 on an old Synology NAS.

Somehow, messing around with my Docker settings, I managed to mess up my Immich installation - Immich opens, but it had me set a new admin account, etc. All of my media still exists locally and on my backup drives, as does the automatic backup file from Immich. I would like to run the backup script from Immich, as seen below and in their page about backups:

docker compose down -v # CAUTION! Deletes all Immich data to start from scratch

## Uncomment the next line and replace DB_DATA_LOCATION with your Postgres path to permanently reset the Postgres database

# rm -rf DB_DATA_LOCATION # CAUTION! Deletes all Immich data to start from scratch

docker compose pull # Update to latest version of Immich (if desired)

docker compose create # Create Docker containers for Immich apps without running them

docker start immich_postgres # Start Postgres server

sleep 10 # Wait for Postgres server to start up

# Check the database user if you deviated from the default

gunzip --stdout "/path/to/backup/dump.sql.gz" \

| sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" \

| docker exec -i immich_postgres psql --dbname=postgres --username=<DB_USERNAME> # Restore Backup

docker compose up -d # Start remainder of Immich apps

The embarrassing question is, where do I input this in Unraid? I built Immich using the Docker Compose Method and while I have a command line input for the immich_server docker application I don't know if it has access to the area where the backup files are generated.

Thank you!

Solved by bmartino1

  • Solution

see guides post for CA and Compose

Docker Guides:

Immich Docker-compose Setup

Immich Unraid-Template in the CA

Please ask questions here.

looks like you went Compose route...

you will need to install the unraid CA Postgres docker and restore your previous postgress database. then update immich to the docker appdata path for immich.

*once you restore the database, the previous immich passord will be needed to connect to the database...

SO, essential install the immich postgress docker I made in the CA.
Run your tools and commands to restore your postgress.

stop the CA docker and add your compose file editing the path to reuse the CA docker data...

-You are responsible for your own data!

Edited by bmartino1
-You are responsible for your own data!

  • Author

@bmartino1 Thank you for your help as well as your work on this project. Please bear with me as I ask a few more questions - I am not smart.

When you advise me to "Run your tools and commands to restore your postgres" - going through the documentation, I believe what I need to do is input the command

gunzip < your_dump.sql.gz | docker exec -i your-db-container psql -U your-db-user -d your-db-name

with my backup, container, etc. information filled in. However, I don't know where to input this. I can open a console to Immich_PostgreSQL but when I input a command with "docker" in it it tells me docker is not found. Should I be using the unraid web terminal?

Thank you!

kinda.

following the documentation from immich
image.png

you will need some form of terminal access.

First I recommend adding a data path to the docker. I will use unraid CA examples atm...

so in the web UI. click the dokcer and edit the docker scrool to the very bottom and

add a path

image.png

link /backup to the path of your immich folder that has the Postgres restore file.

image.png

*This is needed later to use the docker commands and to bring files into the secure container docker environment.
This will make a /backup folder that points to the immich backup that holds the Postgres data we want to restore.


so with a Postgres setup, and the docker running:

image.png

you can click on the docker and go to console.

image.png

This should open a terminal window as if you are at a ssh connection on the machine that is the docker.
here, you need to have a path to the restore file added to the docker.

example ls to see folders (*Note this Doesn't have the backup path made above... just example you should see a backup or what ever you called the container path...)
image.png

it is here that you run sql and other commands to connect to postgres and run the needed commands to restore the backup...

#####################################

With that out of the way...


Why Kinda... So yes. You will need unraid terminal access. However, There are many ways to accomplish the same thing. As The goal here is to get access to a terminal that can connect to the Postgres database to write a sql file to replace and update the database running to restore from a backup.

Other software and dockers exist that can connect to Postgres to run the sql backed up file to restore the database...

So now lets review the immich documentation... Immich from command line since Postgres is a docker we use docker tools and on unraid host(we open the web terminal) we would execute something like this:

docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=<DB_USERNAME> | gzip > "/path/to/backup/dump.sql.gz"

Learn more on docker execute here:

Docker Documentation
No image preview

docker container exec

here, the command is ran to dump the current Postgres database in a docker named immich_postgress. pg_dump is the Postgres command to dump the database to a text file.

Now the other half... if gzip the linux application is installed as database can grow big. it will attempt to compress and make the sql file smaller.

*last i checked, gzip is not a default unraid package and thus ignored the command will fail... you will have a sql file on unrad wher you ran the docker exe command.... However, You can use other tools as well to extract the zip file to get the sql file you need to restore... or compress.

so from the documentation ocne you have the sql file we can then use terminal commands to restore

docker exec -i immich_postgres psql --dbname=postgres --username=<DB_USERNAME> # Restore Backup

this restores the sql file to a database named postgres.

as again many ways to accomplish it..

Postgres's comands
https://www.youtube.com/watch?v=5kPFhTqlRIE

https://www.youtube.com/watch?v=QcZHk70CK0o

and as some what explained here in documentation:

as you will need to get a blank postgress database working with the correct database name and user credential and then run a restore command to get your old sql file on the new Postgres.

Then use the data folder and same docker image in the compose file to reuse your restore.

we can also take a look at Postgres admin docker called pgadmin4
https://hub.docker.com/r/dpage/pgadmin4/

if your not comfortable running terminal commands.

or other 3rd party applicaiton antraes for example

https://antares-sql.app/

that can connect to portgres for use to run the sql file...

Edited by bmartino1
Spelling / Data

  • Author

Thank you so much for bearing with me @bmartino1 ! I was able to get everything restored thanks to your help and the documentation you provided, and it also cleared up a lot of misconceptions I had about how docker works. Thank you again!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.