Immich: Difference between revisions

add tip for borg backup
34j (talk | contribs)
 
(7 intermediate revisions by 5 users not shown)
Line 5: Line 5:
{{file|/etc/nixos/configuration.nix|nix|3=services.immich.enable = true;
{{file|/etc/nixos/configuration.nix|nix|3=services.immich.enable = true;
services.immich.port = 2283;}}
services.immich.port = 2283;}}
To access Immich from other devices via network, add the following as well:
{{file|/etc/nixos/configuration.nix|nix|3=services.immich.host = "0.0.0.0";
services.immich.openFirewall = true;}}
More options are available: {{nixos:option|services.immich.}}  
More options are available: {{nixos:option|services.immich.}}  


== Tips and Tricks ==
== Tips and Tricks ==
=== Custom Media Location ===
While the official Immich documentation recommends modifying <code>UPLOAD_LOCATION</code> environmental variable for Docker build, NixOS does not support modifying it. Instead, {{nixos:option|services.immich.mediaLocation}} may be used, which simply sets [https://docs.immich.app/install/environment-variables/ <code>IMMICH_MEDIA_LOCATION</code>] variable, while this is not recommended in the official documentation:
{{file|/etc/nixos/configuration.nix|nix|3=services.immich.mediaLocation = "/var/lib/immich";
}}
{{warning|If you have used Immich before, changing this option will completely stop Immich service, disabling access from browser. You may need to reset / remove Postgresql database.}}
{{info|If you only need to change the location where raw data is stored, [https://docs.immich.app/guides/external-library/ External Libraries] may be used.}}


=== Enabling Hardware Accelerated Video Transcoding ===
=== Enabling Hardware Accelerated Video Transcoding ===
Line 44: Line 58:
Following Immichs [https://immich.app/docs/administration/backup-and-restore/ backup docs] and [https://immich.app/docs/guides/template-backup-script backup script] an automated backup using [[Borg backup]] could look something like this:
Following Immichs [https://immich.app/docs/administration/backup-and-restore/ backup docs] and [https://immich.app/docs/guides/template-backup-script backup script] an automated backup using [[Borg backup]] could look something like this:
{{File|3=services.borgbackup.jobs."Immich" = {
{{File|3=services.borgbackup.jobs."Immich" = {
   paths = "/var/lib/immich";
   paths = config.services.immich.mediaLocation;
   repo = "<path-to-borg-repo>";
   repo = "<path-to-borg-repo>";
   startAt = "Sat 04:00";
   startAt = "Sat 04:00";
Line 70: Line 84:
Jul 01 14:23:12 server2 immich[178592]:  line: '477',
Jul 01 14:23:12 server2 immich[178592]:  line: '477',
Jul 01 14:23:12 server2 immich[178592]:  routine: 'CheckMyDatabase'
Jul 01 14:23:12 server2 immich[178592]:  routine: 'CheckMyDatabase'
Jul 01 14:23:12 server2 immich[178592]: }</syntaxhighlight>To fix this, run <code>sudo -u immich psql -d immich</code> and execute these to commands:<syntaxhighlight lang="sql" line="1">
Jul 01 14:23:12 server2 immich[178592]: }</syntaxhighlight>To fix this, run <code>sudo -u immich psql -d immich</code> and execute these two commands:<syntaxhighlight lang="sql" line="1">
ALTER DATABASE immich REFRESH COLLATION VERSION;
ALTER DATABASE immich REFRESH COLLATION VERSION;
REINDEX DATABASE immich;
REINDEX DATABASE immich;
Line 78: Line 92:
If you still run into issues after restarting postgresql and immich-server services, some additional postgresql database changes might be necessary to [https://web.archive.org/web/20240910231531/https://docs.pgvecto.rs/admin/upgrading.html#upgrading upgrade pgvecto.rs table]:
If you still run into issues after restarting postgresql and immich-server services, some additional postgresql database changes might be necessary to [https://web.archive.org/web/20240910231531/https://docs.pgvecto.rs/admin/upgrading.html#upgrading upgrade pgvecto.rs table]:


Run <code>sudo -u postgresql psql</code> and execute consecutively:<syntaxhighlight lang="sql" line="1">
Run <code>sudo -u postgres psql</code> and execute consecutively:<syntaxhighlight lang="sql" line="1">
CREATE EXTENSION IF NOT EXISTS unaccent;  
CREATE EXTENSION IF NOT EXISTS unaccent;  
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";  
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";  
Line 88: Line 102:
SELECT pgvectors_upgrade();
SELECT pgvectors_upgrade();
</syntaxhighlight>Finally, restart postgresql and immich: <code>systemctl restart postgresql && systemctl restart immich-server</code>
</syntaxhighlight>Finally, restart postgresql and immich: <code>systemctl restart postgresql && systemctl restart immich-server</code>
=== Immich server too old on NixOS stable ===
If you encounter errors like <code>Error processing stream</code> or <code>Error in runInIsolateGentle for remote-sync</code> on Android/iOS clients, the cause may be that the Immich server version packaged in <code>nixos-stable</code> is behind the mobile apps. 
You can use the Immich package from <code>nixos-unstable</code> while keeping the rest of your system on stable. Add the following to the top of your <code>/etc/nixos/configuration.nix</code>: 
<syntaxhighlight lang="nix" line>
let
  unstableTarball = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
in {
  nixpkgs.config = {
    packageOverrides = pkgs: {
      unstable = import unstableTarball {
        config = config.nixpkgs.config;
      };
    };
  };
}
</syntaxhighlight>
Then override the Immich package in your service config: 
<syntaxhighlight lang="nix" line>
services.immich.package = pkgs.unstable.immich;
</syntaxhighlight>
[[Category:Server]]
[[Category:Server]]
[[Category:Web Applications]]
[[Category:Web Applications]]