Conversation
Titaniumtown
left a comment
There was a problem hiding this comment.
LGTM over all. I have a few nits, besides that. Thank you for the informative docs! I'm going to personally follow this guide now haha.
619fc4f to
facf01c
Compare
facf01c to
7220cb6
Compare
7220cb6 to
2f41434
Compare
getchoo
left a comment
There was a problem hiding this comment.
Mostly some punctuation nitpicks
|
@getchoo if you have this many tiny adjustments to recommend, it's usually easier for everyone involved to just PR them against the PR branch. |
Signed-off-by: Sefa Eyeoglu <[email protected]>
af33b50 to
e7fae70
Compare
|
hi, I followed this guide and got stuck with some permission problems. inside my container based setup, the database user and owner of the tables was if you come across this issue, you can run this command on your db dump: after that, it worked like a charm and all my images, users, faces etc popped up with no issues :) thanks for writing up this guide!! |
|
I think I ran into that when I did my manual migration before this guide's existence too. The guide should probably cover that. |
|
Hi, i followed this guide, and i ran into an issue with the database, it says that the migrations relations already exists: |
|
@mhdask please share some info such as which version you're migrating from. Also please just try again (wipe and everything), perhaps you just accidentally did something differently. |
I am migrating from 1.115.0 to 1.116.2 If i do a |
hahahah, very good point. My library is only a few thousand photos and I haven't done much with it yet. |
Im not sure which two dumps you want to compare, the one from the original (docker) database dump, and the new nixos service version? UPDATE: |
akho
left a comment
There was a problem hiding this comment.
Thank you for the guide. Commented on two points which caused issues. I think we need someone to run this beginning-to-end one more time.
Signed-off-by: Sefa Eyeoglu <[email protected]>
e7fae70 to
2d4b7ce
Compare
akho
left a comment
There was a problem hiding this comment.
Both points seem fixed, thank you.
I’ve already done things in my new module-based install, so it’s not easy to do a run-through the new version as-is...
|
I've also had to re-create my external libraries, due to path mismatches with the container. Only noticed this now. Not sure what should have been done at db dump level. This is really unfortunate, though — a lot of photos there… |
|
Shouldn't you only have to adjust the import paths of the existing libraries? You can do that in the UI without touching the db. |
Didn’t work for me. |
|
Should we merge this as-is? I think we could also move this into the NixOS wiki alternatively and allow people to refine it there. |
I don't think that would be too bad of an idea. This is a pretty big section in the manual for something that's fairly specific |
|
I feel like it's worth having in the official channel-specific "proper" documentation rather than the wiki. I've been meaning to have another look, try it and then merge but I've been putting off migrating my Immich setup... |
|
I just completed my migration and I would like to share my experience following this guide.
sed -E "s#upload/([^\t]+)/#$TARGET_LOCATION/\1/#g" ./immich-fixed-search-path.sql > ./immich-final.sql
|
Following migration guide from NixOS/nixpkgs#344300
Following migration guide from NixOS/nixpkgs#344300
Following migration guide from NixOS/nixpkgs#344300
|
Not sure if this is worth adding to this PR (or future wiki entry), but I was already using NixOS's PostgreSQL database, so I didn't have to move it around, just to change the paths in the data. START TRANSACTION;
UPDATE "asset_files" SET "path" = regexp_replace("path", '^upload/', '/persist/immich/');
UPDATE "assets" SET "originalPath" = regexp_replace("originalPath", '^upload/', '/persist/immich/');
UPDATE "assets" SET "encodedVideoPath" = regexp_replace("encodedVideoPath", '^upload/', '/persist/immich/');
UPDATE "assets" SET "sidecarPath" = regexp_replace("sidecarPath", '^upload/', '/persist/immich/');
UPDATE "move_history" SET "oldPath" = regexp_replace("oldPath", '^upload/', '/persist/immich/');
UPDATE "move_history" SET "newPath" = regexp_replace("newPath", '^upload/', '/persist/immich/');
UPDATE "person" SET "thumbnailPath" = regexp_replace("thumbnailPath", '^upload/', '/persist/immich/');
UPDATE "users" SET "profileImagePath" = regexp_replace("profileImagePath", '^upload/', '/persist/immich/');
COMMIT;Either way, just wanted to leave this as a comment in case someone stumbles upon it. |
Atemu
left a comment
There was a problem hiding this comment.
This guide did not work for my docker-compose based setup and needs to be changed accordingly.
Additionally I think @diogotcorreia's method of modifying the data via SQL feels a little cleaner but OTOH we need to modify the SQL dump anyways for the search path. (Postgres really ought to have a flag to just allow it.)
This is not something that needs to be implemented in this PR though.
Once that is fixed, this looks very good to me and we should have it.
|
|
||
| These are assumptions and goals of this migration guide: | ||
|
|
||
| 1. Your current installation's database name and username is `immich`. |
There was a problem hiding this comment.
This assumption was not true for me and apparently multiple others too.
There needs to be a step that does:
sed -i 's/OWNER TO postgres/OWNER TO immich/g'
Otherwise you get confusing errors on startup such as "Must be owner of table exif" or that the table migrations already exists.
|
|
||
| Example: | ||
| ```console | ||
| # docker stop immich_server immich_machine_learning |
There was a problem hiding this comment.
Nit:
The way I did it which I think is slightly better is to docker compose down and then docker compose up database. This ensures only the DB is running which is what we want in this step.
| named `immich_postgres`: | ||
|
|
||
| ```console | ||
| # docker exec immich_postgres pg_dump --username immich immich > /var/backup/immich.sql |
There was a problem hiding this comment.
The username needs to be postgres here.
| # docker exec immich_postgres pg_dump --username immich immich > /var/backup/immich.sql | |
| # docker exec immich_postgres pg_dump --username postgres immich > /var/backup/immich.sql |
If this is not postgres in regular setups people actually have, perhaps this should be an env var too.
| the following `sed` command: | ||
|
|
||
| ```console | ||
| # sed "s#upload/(.*)/#$TARGET_LOCATION/\1/#g" ./immich-fixed-search-path.sql > ./immich-final.sql |
There was a problem hiding this comment.
Oh, right and this didn't work for me at all.
@karb94's command worked for me:
| # sed "s#upload/(.*)/#$TARGET_LOCATION/\1/#g" ./immich-fixed-search-path.sql > ./immich-final.sql | |
| # sed -E "s#upload/([^\t]+)/#$TARGET_LOCATION/\1/#g" ./immich-fixed-search-path.sql > ./immich-final.sql |
There was a problem hiding this comment.
For some reason, my installation was using absolute paths like /usr/src/app/upload/thumbs/... for some paths, but not all. I had to use sed -E "s#(^|\s)(/usr/src/app/)?upload/([^\t]+)/#\1/srv/large/photos/immich/\3/#g" ./immich-fixed-search-path.sql > ./immich-final.sql.
| `immich-machine-learning.service` units. | ||
|
|
||
| ```console | ||
| # systemctl stop immich-server.service immich-machine-learning.service |
There was a problem hiding this comment.
Nit: It's slightly cleaner to stop these via the provided slice as that includes all of Immich's services in case there are any new ones in the future.
| # systemctl stop immich-server.service immich-machine-learning.service | |
| # systemctl stop system-immich.slice |
| Now that we prepared the database as well as the media location, we can finally start Immich and its other components: | ||
|
|
||
| ```console | ||
| # systemctl start immich-server.service immich-machine-learning.service |
There was a problem hiding this comment.
| # systemctl start immich-server.service immich-machine-learning.service | |
| # systemctl start system-immich.slice |
|
I had to adapt the path-fixing step slightly, because my database had a mix of absolute paths ( So this is the script that worked for me: START TRANSACTION;
UPDATE "system_metadata" SET "value" = regexp_replace("value"::TEXT, '"(/usr/src/app/)?upload"', '"$TARGET_LOCATION/immich"')::JSONB WHERE "key" = 'MediaLocation';
UPDATE "asset_file" SET "path" = regexp_replace("path", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/');
UPDATE "asset" SET "originalPath" = regexp_replace("originalPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/'),
"encodedVideoPath" = regexp_replace("encodedVideoPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/'),
"sidecarPath" = regexp_replace("sidecarPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/');
UPDATE "move_history" SET "oldPath" = regexp_replace("oldPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/'),
"newPath" = regexp_replace("newPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/');
UPDATE "person" SET "thumbnailPath" = regexp_replace("thumbnailPath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/');
UPDATE "user" SET "profileImagePath" = regexp_replace("profileImagePath", '^(/usr/src/app/)?upload/', '$TARGET_LOCATION/immich/');
COMMIT;I strongly recommend against including the sed path fixer in the final document. Postgres already provides a much more robust way to do what's needed without trying to parse sql dumps with regex. |
|
I believe the |
|
Maybe we should just have this in the NixOS Wiki instead. |
Description of changes
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.