This is a simple Pyhon script, dressed as a Docker container, that removes Offline Files from External Immich libraries. It can be used to either run the script manually, or via cronjob by providing a crontab expression to the container. The container can then be added to the Immich compose stack directly.
Instructions can be found in the Immich docs - Obtain the API key
To perform a manually triggered run, use the following command:
docker run --rm -e API_URL="https://immich.mydomain.com/api/" -e API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e OFFLINE_THRESHOLD=100 ghcr.io/tenekev/immich-offline-files-remover:latest /script/immich_auto_remove_offline_files.sh
docker run --name immich-offline-files-remover -e TZ="Europe/Sofia" -e CRON_EXPRESSION="0 * * * *" -e API_URL="https://immich.mydomain.com/api/" -e API_KEY="xxxxx" -e OFFLINE_THRESHOLD=100 ghcr.io/tenekev/immich-offline-files-remover:latest
Adding the container to Immich's docker-compose.yml
file:
version: "3.8"
...
services:
immich-server:
container_name: immich_server
...
immich-offline-files-remover:
container_name: immich-offline-files-remover
image: ghcr.io/tenekev/immich-offline-files-remover:latest
restart: unless-stopped
environment:
API_URL: http://immich_server:3001/api
API_KEY: xxxxxxxxxxxxxxxxx # https://immich.app/docs/features/command-line-interface#obtain-the-api-key
OFFLINE_THRESHOLD: 100 # If the number of offline files exceed this number, they won't be cleaned. Indicates an issue with availability.
CRON_EXPRESSION: "0 */1 * * *" # Run every hour
TZ: Europe/Sofia
You can still trigger the script manually by issuing the following command in the container shell:
/script/immich_auto_remove_offline_files.sh
Or with Docker exec:
docker exec -it immich-offline-files-remover /script/immich_auto_remove_offline_files.sh
This project is licensed under the GNU Affero General Public License version 3 (AGPLv3) to align with the licensing of Immich, which this script interacts with. For more details on the rights and obligations under this license, see the GNU licenses page.