this post was submitted on 30 Apr 2024
32 points (94.4% liked)

Selfhosted

40201 readers
889 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] Esca@lemmy.one 1 points 6 months ago (5 children)

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 1 points 6 months ago (4 children)

(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 1 points 6 months ago* (last edited 6 months ago) (3 children)

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 1 points 6 months ago (1 children)

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 1 points 6 months ago (1 children)

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 1 points 6 months ago

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

load more comments (1 replies)
load more comments (1 replies)
load more comments (1 replies)