Would this flow work with Immich & Syncthing to copy images and auto upload and delete?
from Mir@programming.dev to selfhosted@lemmy.world on 30 Apr 03:58
https://programming.dev/post/13442819

I would like new images to be uploaded to Immich from my phone and deleted after 30 days automatically, so I was thinking about this flow:

  1. I will Sync files to the server using Syncthing

  2. I will Copy files from the Synced folder to an Immich Consume folder, (not sure how to copy only new files (maybe use created date)). Then delete images that are older than 30 days which will remove them from my phone.

  3. I will upload to Immich using Immich CLI (?) which will use the delete after upload flag.

Basically:  

(1)

Camera, Screenshots, etc =Syncthing=> SyncthingImageConsume/{Folder}

(2)

{Script on SyncthingImageConsume}

SyncthingImageConsume/{Folder} =CopyNewFiles=> ImmichConsume/{Folder}

Then delete older than 30 days.

(3)

{Script on ImmichConsume}

Upload to immich and then delete

 

would this work? and is there a better way to do it? any tips?

#selfhosted

threaded - newest

barbara@lemmy.ml on 30 Apr 04:46 next collapse

Better ways to upload images to immich?

Maybe it’s a weird idea but did you try immich’s upload feature?

Mir@programming.dev on 30 Apr 04:55 collapse

I don’t want to manually upload pictures, I want new photos to be uploaded to Immich automatically and deleted from my phone after 30 days.

Also the Immich backup on android is very limited, I can’t find all folders in the list it’s giving me

ShortN0te@lemmy.ml on 30 Apr 08:43 collapse

Why not file a bug report when it does not find all your photos?

Also may file a feature request to delete photos after set period from your device via immich?

Mir@programming.dev on 30 Apr 11:20 collapse

I will make sure that this doesn’t exist first before requesting a feature, thanks for the tip

Lifebandit666@feddit.uk on 30 Apr 06:51 next collapse

Could Rsync help? In OMV I can Rsync shares and it will check the folder I’m syncing to and just upload new files.

So you could Syncthing to the server folder then Rsync that folder to your Immich at xam every day, then just manually delete things from your Syncthing folder occasionally.

Mir@programming.dev on 30 Apr 11:21 collapse

Oh that might be perfect. I will look into it, thank you!

rambos@lemm.ee on 30 Apr 08:53 next collapse

Feels like you want a regular Immich auto upload and a custom script that deletes old images from your phone. I can’t help with that script, but maybe also I missunderstood what is your goal

Mir@programming.dev on 30 Apr 11:18 collapse

More or less yes. Except that the auto upload is limited I can’t figure out why most of albums aren’t showing

rambos@lemm.ee on 01 May 13:09 collapse

Don’t expect albums in immich after upload. Immich will just put everything in timeline (by default) and you should make albums manually.

Also, make sure you have exactly the same app version as server

couch1potato@lemmy.dbzer0.com on 02 May 00:46 next collapse

I have albums generate automatically… see my posts above

Mir@programming.dev on 02 May 02:08 collapse

I just noticed something else that is mildly annoying, after I move them to album I have to run the template migration job to move to the correct folder.

Shimitar@feddit.it on 30 Apr 10:19 next collapse

Why such a mess? Either use immich with its upload or use syncthing (I use the latter).

Immich sucks in providing folder based albums, but excells in phone photo backup and sync!

Mir@programming.dev on 30 Apr 11:18 collapse

I want to use immich mostly for viewing

Shimitar@feddit.it on 30 Apr 12:25 next collapse

There are better options for viewing… Imho

Mir@programming.dev on 30 Apr 13:06 collapse

can you recommend me something else?

Shimitar@feddit.it on 30 Apr 14:21 collapse

There are many.

Personally I use both PiGallery2 (great folder view, super fast) and HomeGallery (innovative browsing approach, modern looks).

They will both work with your existent file/folder structure and will update as you add or remove photos.

Mir@programming.dev on 01 May 22:15 collapse

Thank you for the suggestion, they seem to be readonly, I was hoping I could delete/rename photos using them.

Shimitar@feddit.it on 02 May 04:04 collapse

Piwigo then, but its old, feels old, its slow and ugly.

rambos@lemm.ee on 01 May 13:00 collapse

You can use external libraries in immich. You just point to any folder on your disk and you can see everything, but can’t edit files. Timeline, maps, face recognition, search,…everything works and you can still keep folder organized images.

Personally I use both. Auto upload everything from my phone (camera, screenshots, etc) and also using external library as folder structured pictures from nextcloud. It doesn’t create albums automatically tho

Mir@programming.dev on 01 May 22:16 collapse

My problem is that external libraries are readonly

Esca@lemmy.one on 30 Apr 13:49 next collapse

I understand you. I also don’t use the auto upload feature as it’s creating more problems for me to solve than what it fixes. I already had Syncthing running anyway so I currently use that combo (except I manually sort through my photos on a semi-weekly basis before I upload it to Immich).

If you want, I can cook up a little Python script you could stick into Cron to do all the tasks you described. I haven’t worked with the Immich CLI yet but I’m sure I can figure it out. Send me a message if you’re interested. I will probably use it myself as well.

Mir@programming.dev on 30 Apr 19:00 collapse

(except I manually sort through my photos on a semi-weekly basis before I upload it to Immich).

I think that would be a better approach if I weren’t very lazy, I think even after the initial run I could do that since I don’t take lots of pictures but I was thinking about a fire and forget sort of thing.

If you want, I can cook up a little Python script you could stick into Cron to do all the tasks you described.

Thank you so much, I asked ChatGPT and it generated the bat file below (since I’m using Windows) do you think this would work?

@echo off
REM Change directory to your photos folder
cd /d "C:\path\to\your\photos\folder"

REM Sync files to backup folder
robocopy . "C:\path\to\your\Camera_Backup" /mir /xo

REM Delete files older than 15 days
forfiles /p "C:\path\to\your\photos\folder" /s /m *.* /d -15 /c "cmd /c if @isdir==FALSE del @file"

REM Upload assets using immich cli
immich upload "C:\path\to\your\Camera_Backup" -r -a --delete
Esca@lemmy.one on 30 Apr 20:45 collapse

Ah, I am not familiar at all with Windows, so I honestly wouldn’t know. Does the Immich CLI even work on Windows?

But going off by the comments and the parts I understand, I guess it could kinda work, assuming that the arguments are all correct. Although, it will try to upload all photos every time, regardless if Immich already has them or not. Which is not ideal but I believe Immich will filter out duplicated photos. But it’s worth checking if it’s indeed smart enough to do that.

For the Immich command it will upload the files to an album called “Camera_Backup”. Not sure if that’s what you want. If not, then remove the -a flag. If you want to upload it to a specific album, then instead add ‘-A albumname’ (edit: I realize I might be wrong here. If you have multiple folders in Syncthing you’re backing up it will work differently)

Mir@programming.dev on 01 May 22:13 collapse

Although, it will try to upload all photos every time

I will use the argument which makes it delete after upload, this way if it wasn’t deleted then it wasn’t uploaded and needs to be uploaded, hopefully the CLI is smart to do so.

I want it to use the folder name as album name, I was hoping that it would do the same for nested folders

Esca@lemmy.one on 02 May 07:06 collapse

The --delete flag is already in there so it should empty the camera_backup folder, but the robocopy will copy every single photo back into it the next run.

Mir@programming.dev on 02 May 07:42 collapse

Ah yes that just downed on me today, I need to figure out how to only copy new items

couch1potato@lemmy.dbzer0.com on 01 May 05:49 collapse

I just set up something similar a couple weeks ago because I wanted to upload named album folders as albums into immich.

Workflow is:

Syncthing to sync phone folder to folder on unraid server.

2nd syncthing instance to sync above folder to “photo albums” folder.

Immich-go cron job runs hourly to upload photo albums folder to immich

I used immich-go because the CLI upload with album tag kept failing and apparently it’s a common issue so… ¯\_(ツ)_/¯ immich-go worked first try.

Now all my photos are uploaded as albums with no manual input:

<img alt="" src="https://lemmy.dbzer0.com/pictrs/image/5b9c8856-5a78-4605-9192-178a842d634a.jpeg">

Mir@programming.dev on 01 May 22:11 next collapse

Thank you. First person to not advise me to use something other than immich for this. And thanks for the heads up about the CLI, can you share the upload script?

couch1potato@lemmy.dbzer0.com on 02 May 00:41 collapse

Sure… I’m on unraid…

cd /mnt/user/appdata_docker/immich/immich-go
./immich-go -server=http://192.168.20.1:8080 -key=IMMICH_API_KEY upload -create-album-folder -when-no-date=FILE /mnt/user/photo_libraries```


![](https://lemmy.dbzer0.com/pictrs/image/5155dc7f-1545-4e07-b7ec-4721e5fec43a.jpeg)


There are other flag arguments that may be applicable to your use case... I'd suggest finding immich-go documentation on github and reading. It's not that intense of a read.
Mir@programming.dev on 02 May 00:30 collapse

Can you tell me about the syncthing set up, how do you have the folders set up to sync?

for instance I have DCIM with folders inside it, do you sync the whole folder or for each folder inside it like “Camera, Screenshot” etc?

couch1potato@lemmy.dbzer0.com on 02 May 01:05 next collapse

I created a specific folder to move family photos to that syncs with the server, because i use my phone for work pictures too and I don’t want those to end up on my immich timeline. So I manually move photos to that folder, but that’s the only manual intervention for me.

I set up the album handling the way I did because my wife spent a lot of time sorting stuff into folders and she wanted the organized folders to carry over to immich.

I do separately sync the DCIM folder to server with syncthing as well, just as a backup, but those don’t go to immich.

So for immich destined items it looks like:

  1. Manually move pics to phone “family photos” folder

  2. Syncthing-ext syncs phone folder “family photos” to server folder “syncthing_folders/my_family_pics”. (Also syncs phone folder “DCIM” to server folder “syncthing_folders/phone_pics_backup”)

  3. Syncthing-int (second syncthing instance on different port, so syncthing-ext and syncthing-int see each other as different devices and can work on the same folders) syncs server folder “syncthing_folders/my_family_pics” to some other designated server folder to work with immich… for example “photo_libraries/my_family_pics”

  4. The script I shared runs on server folder “photo_libraries/”

It’s set up this way because I have syncthing-ext syncing with a bunch of external devices and this way i can funnel just the photo folders into one photo library folder to run the script on.

If you have more questions it’s cool… I never get to talk about this stuff with anyone who appreciates it 😶‍🌫️

Mir@programming.dev on 02 May 02:19 collapse

Thank you so much, perfect explanation.

Do you keep the stuff on your phone then? how does syncthing handles deleting if you’re deleting? did you set up the folder as send only?

I’m working on setting it up for me to do so:

  1. Manually move some pics on my phone to “Inbox” folder (To be sorted in albums later)
  2. Syncthing will automatically sync “Inbox” and “Camera” folders to "Syncthing Consume"
  3. A job to copy from “Syncthing Consume” to "Immich Consume"
  4. Immich Go will move everything to Immich
  5. Anything in the Inbox Album will get sorted to different albums at some point
  6. Eventually anything that isn’t synced will be removed from my phone
couch1potato@lemmy.dbzer0.com on 02 May 02:31 collapse

Yeah the phone folder is send only and the server syncthing-ext folder is receive only.

I never really find myself deleting stuff because I don’t take that many pictures/videos, but my wife is the one always running out of space. I’ve told her when she sees her album in immich it’s safe to delete from the phone.

I’m not sure how you’d automate deleting stuff while making sure you’re not deleting items that haven’t been sent yet… but, it’s not really something I’m interested in because I don’t have the need.

Another good practice (at least I’d like to think so), my syncthing-int which sends everything to /photo_libraries also sends everything to two other backup folders that are pinned to separate discs. So if I have a drive failure or multiple drive failures I’d still have a copy of all the photos/albums.

Mir@programming.dev on 02 May 02:48 collapse

I’m not sure how you’d automate deleting stuff while making sure you’re not deleting items that haven’t been sent yet

Yeah this will be very tricky, I’m thinking if I got over the initial push to Immich, I just delete manually from my phone when I see things have already moved to Immich and I don’t need it anymore.

Another good practice (at least I’d like to think so), my syncthing-int which sends everything to /photo_libraries also sends everything to two other backup folders that are pinned to separate discs. So if I have a drive failure or multiple drive failures I’d still have a copy of all the photos/albums.

I will do that to ensure I’ve backed everything up somewhere in case an Immich Failure.

couch1potato@lemmy.dbzer0.com on 02 May 01:31 collapse

<img alt="" src="https://lemmy.dbzer0.com/pictrs/image/6f178905-5869-4bf1-84f0-1685d013b1ed.jpeg">

A picture if that makes it easier