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.

immich auto-upload user script

Featured Replies

I've been able to bulk upload photos to Immich manually through the command line by going to my Docker tab, finding the Immich container, clicking ">_ Console" and running the command:

immich upload --key HFEJ38DNSDUEG --server http://192.168.1.216:2283/api --recursive directory/

This works fine, but I'd like to automate this using userscripts so that it runs automatically from time to time. I don't know much about writing scripts though - I've tried a few things but haven't gotten it to work.

 

If I click the ">_" button at the top of my GUI for the UNRAID terminal, and run:

docker exec -it immich bash

 

I can get into the docker container, so my userscript looks like this:

#!/bin/bash
docker exec -it immich bash
immich upload --key HFEJ38DNSDUEG --server http://192.168.1.216:2283/api --recursive directory/

 

When I run that though I get the error:

Quote

the input device is not a TTY
/tmp/user.scripts/tmpScripts/immich test/script: line 3: immich: command not found

 

I've also tried running:

docker exec -it immich upload --key HFEJ38DNSDUEG --server http://192.168.1.216:2283/api --recursive directory/

but get an error message telling me that the upload command is not found.

 

 

 

 

I'm pasting in the generic 'immich upload' command from the Immich website, the command that I'm running has my correct API key, IP address & upload source directory.

 

 

 

Can anyone suggest a way to set up my user script so that I can run it on a schedule to grab any photos that I put into the upload source directory?

 

 

Another item that I'm concerned about once I get the first part running - when I run the immich upload command through the docker console, there is a message that says something like 'you're about to upload ### photos, are you sure?' and then I have to enter y/n. Is there a way to make sure that the user script can confirm 'y' for me?

 

Edited by romain
added more details.

  • 6 months later...

Did you fixed this?

  • 1 month later...

In case anybody else winds up here looking for a solution--I was able to get this working with a couple of changes to romain's script:

 

#!/bin/bash
docker exec immich bash
docker exec immich upload --recursive directory/

 

The changes were 1) removing the "-it" flags, which are for interactive use (not a script) and 2) adding the docker exec command before the upload command.  I didn't need to pass the server address or API key, because those are permanently stored in an auth.yml file that was created after I ran the following command, which was only needed once:   

 

immich login http://192.168.0.45:8080/api [API key]

 

The upload command doesn't display a progress bar when it is running, but it does complete the upload.

Edited by MastodonFarm

  • 6 months later...

I have a quick question just to make sure i understand.
 

#!/bin/bash
docker exec immich bash
docker exec immich upload --recursive directory/


"directory/ " would be the path of where the photos/videos that I want to upload are located?

 

#!/bin/bash
docker exec immich bash
docker exec immich upload --recursive /user/folders/pictures/


or do I need to keep "directory/ " and the path follows the ending / ?

  • Community Expert

?

if the docker and data are on unraid why not add a path

Example docker variable:
-v /upload:/mnt/user/picture
then call the imichi upload pointing at /upload

???
immich is still a bit new for me. I've been playing around with it with a friend.

if you followed space invaders videos to install imichi then this folder in the template should already exist:
image.png.2e20ce85df694206af0bbc5821bb7316.png
-- the libraries folder path....

 

then the script can point into the docker to that folder path...

Edited by bmartino1
Data - typo

  • Community Expert

To automate the upload process for Immich in Unraid with a userscript, you can address the two issues you encountered:

 

...

Handling non-TTY errors and command not found:

You don't need to start an interactive session (bash) inside the container.

Use docker exec directly to run the immich command.


...a bit harder but possible...

Automating the confirmation step:

You can use yes to automatically send "y" responses to the command.

 

#!/bin/bash

# Variables
CONTAINER_NAME="immich"
UPLOAD_DIRECTORY="/path/to/your/upload/source"
API_KEY="HFEJ38DNSDUEG"
SERVER_URL="http://192.168.1.216:2283/api"

# Run the upload command within the container
docker exec $CONTAINER_NAME immich upload \
  --key $API_KEY \
  --server $SERVER_URL \
  --recursive $UPLOAD_DIRECTORY <<< "y"

 

Steps to Configure:

 

Replace placeholders:

Replace /path/to/your/upload/source with the absolute path inside the container (e.g., /photos or /libraries as configured in your volume mappings).

Replace HFEJ38DNSDUEG with your actual API key.

Replace http://192.168.1.216:2283/api with your Immich server URL.

 

Save this script in the User Scripts plugin in Unraid, ensuring the path to the script is correct.

--set and use cron via the userscript plugin.

 

Notes:

Ensure the immich binary is available in the container. If not, check the Immich documentation or support for enabling this.

If the <<< "y" doesn't work (unlikely), consider using yes y | before the command.

#!/bin/bash

# Variables
CONTAINER_NAME="immich"
UPLOAD_DIRECTORY="/path/to/your/upload/source"
API_KEY="HFEJ38DNSDUEG"
SERVER_URL="http://192.168.1.216:2283/api"

# Run the upload command within the container, piping 'yes' to confirm
yes y | docker exec $CONTAINER_NAME immich upload \
  --key $API_KEY \
  --server $SERVER_URL \
  --recursive $UPLOAD_DIRECTORY

 

Edited by bmartino1

  • 6 months later...

This works for me:

docker exec immich immich login http://192.168.1.24:8080/api ANTDH19gwRb4EeOH9I0B7BZmOPGW

# Upload de bestanden
docker exec immich immich upload --recursive --delete /libraries

docker exec immich immich logout

(no, this is not my actual ip or api-key)

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.