I
Immich•2mo ago
MeshmeZ

auto backup and storage template

Hi, im essentially trying to create a backup server for my phone albums. I would like to automatically backup new pictures in an album on my phone, to an album on immich. I would also like to have the files saved in a folder labeled with the album name, and the file name unchanged. currently what i have going is my phone set to backup my "camera" album, and Storage template set to {{album}}/{{filename}} when i initially backed up, all the photos from my phone "camera" album were just dumped in the root library folder. running Storage template migration successfully put them into a folder called "camera" When i take a new picture on my phone it goes to the "camera" album on my phone. it is then backed up to the immich library automatically as desired. however, the file is once again put in the root library folder, and isnt added to the "camera" album on immich . And running storage template migration does NOT move it to the "camera" folder. How can i get new backups to go into the folder and album corresponding to their albums on my phone?
59 Replies
Immich
Immich•2mo ago
:wave: Hey @MeshmeZ, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :blue_square: verified I'm on the latest release(note that mobile app releases may take some time). 2. :blue_square: read applicable release notes. 3. :blue_square: reviewed the FAQs for known issues. 4. :blue_square: reviewed Github for known issues. 5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy). 6. :blue_square: uploaded the relevant information (see below). 7. :blue_square: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed.
schuhbacca
schuhbacca•2mo ago
Do you have the "Sync Albums" setting set on your phone
MeshmeZ
MeshmeZOP•2mo ago
yes, i do is adding to the album and moving the file to the folder something that takes time? maybe im not waiting long enough?
schuhbacca
schuhbacca•2mo ago
Is this for items that are uploaded in the background?
MeshmeZ
MeshmeZOP•2mo ago
yes.
Immich
Immich•2mo ago
[Issue] Album sync issues during background backup (immich-app/immich#22590)
schuhbacca
schuhbacca•2mo ago
I think it's a current limitation of the background upload but not 100% sure
MeshmeZ
MeshmeZOP•2mo ago
ok i will read through that, thanks! Is there a different/better way to do it? essentially i want certain albums on my phone to be backed up into folders on my NAS. and then be able to share them from there. opening the app on my phone seems to put the image in the correct album in immich, but does not update the storage location
schuhbacca
schuhbacca•2mo ago
Yeah that's the problem. Once the app opens, it will correctly sync the album data, but the asset has already been uploaded so it doesn't get moved on the server. The storage template runs right after the asset uploads To work around this the only thing I can think of is to automate calling the "Storage Template" migration job via the api with like cron, to have it run periodically At least until this can be addressed in the future
MeshmeZ
MeshmeZOP•2mo ago
ya the problem is you lost me at automation 🙂 but it also seems like periodically ruinning the migration would not help unless it was run at the same time as the background upload?
schuhbacca
schuhbacca•2mo ago
If you open the app, it will sync the camera album. Then if you run the storage template migration, it will move on the file system
MeshmeZ
MeshmeZOP•2mo ago
ahh... i see... now that i have opened the app it has tagged the file correctly, and the migration does move the file
schuhbacca
schuhbacca•2mo ago
Correct So it's a race condition currently
MeshmeZ
MeshmeZOP•2mo ago
i see. ok this isnt "great" but its at least workable. i just have to open the app periodically and run the migration periodically, and it will file everything correctly.
schuhbacca
schuhbacca•2mo ago
Unfortunatley if you don't know how to call the api on a schedule, you will manually have to do it right now
MeshmeZ
MeshmeZOP•2mo ago
and in the mean time, my files are still being automatically backed up, just not filed how i want them
schuhbacca
schuhbacca•2mo ago
Yep, open bug
MeshmeZ
MeshmeZOP•2mo ago
ok, at least now i understand what is going on, and that i wasnt just doing it wrong. Thank you! where would i look to learn how to set up the automation?
MeshmeZ
MeshmeZOP•2mo ago
hmm ya i dont know that im going to be able to get there. hopefully it gets updated to run automatically later. haha Ok, i realize no one is going to want to fully walk me through this... but im trying... can someone tell me if there is somthing im missing here? my crontab looks like this: (updating time as i try it) 26 10 * * * /volume1/docker/Immich/storetemp2.sh My script in storetemp2.sh looks like this #!/bin/bash curl -L -X PUT 'http://mynasip:2283/api/jobs/storageTemplateMigration' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'x-api-key: API key for job permissions' \ -d '{ "command": "start", "force": false }'
schuhbacca
schuhbacca•2mo ago
I can take a look at this a little later
MeshmeZ
MeshmeZOP•2mo ago
thank you!
Zeus
Zeus•2mo ago
Is the script even running? Whats the output when you run it manually? Theres a lot of debugging you can do here
MeshmeZ
MeshmeZOP•2mo ago
when i run ./volume1/docker/Immich/storetemp2.sh it says cannot execute: required file not found EDIT: discovered i was doing ./ instead of . / But i also ran 1 10 * * * usr/bin/echo "test" >> /volume1/docker/Immich/test.txt in crontab and it worked and put the file in that path and yes, storetemp2.sh is in that path and i ran chmod +x /volume1/docker/Immich/storetemp2.sh I ran: bash /volume1/docker/Immich/storetemp2.sh And it gave me : {"message":"Authentication required","error":"Unauthorized","statusCode":401,"correlationId":"zdvzprrq"}curl: (3) URL using bad/illegal format or missing URL /volume1/docker/Immich/storetemp2.sh: line 3: -H: command not found /volume1/docker/Immich/storetemp2.sh: line 4: -H: command not found /volume1/docker/Immich/storetemp2.sh: line 5: -H: command not found /volume1/docker/Immich/storetemp2.sh: line 9: -d: command not found
Mraedis
Mraedis•2mo ago
I think you simply have a typo somewhere in your script @MeshmeZ
MeshmeZ
MeshmeZOP•2mo ago
thats what i think too, but i have no clue what im doing, so i cant identify it haha i copied the text from here: https://discordapp.com/channels/979116623879368755/1371777130207117344/1371899163515551847
Mraedis
Mraedis•2mo ago
I did too, literally are you sure you're not missing the \ at the end
MeshmeZ
MeshmeZOP•2mo ago
i am. ill try it
Mraedis
Mraedis•2mo ago
You can't put different parts of a command on different lines without the \ either add the \ or just put it all after one another
MeshmeZ
MeshmeZOP•2mo ago
do you mean do this: -d '{"command": "start","force": false}'\ instead of this? -d '{ "command": "start", "force": false }'
Mraedis
Mraedis•2mo ago
No
Mraedis
Mraedis•2mo ago
No description
MeshmeZ
MeshmeZOP•2mo ago
#!/bin/bash curl -L -X PUT 'http://nasIP:2283/api/jobs/storageTemplateMigration' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'x-api-key: permissionsapikey' \ -d '{ "command": "start", "force": false }'
Mraedis
Mraedis•2mo ago
all looks fine to me...
MeshmeZ
MeshmeZOP•2mo ago
and to make sure im not soing something silly... this is in a .sh file
Mraedis
Mraedis•2mo ago
yes the file extension doesn't actually matter though
Mraedis
Mraedis•2mo ago
No description
Mraedis
Mraedis•2mo ago
bash --version maybe your bash is ancient
MeshmeZ
MeshmeZOP•2mo ago
so if i run chmod +x /volume1/docker/Immich/storetemp2.sh and then . /volume1/docker/Immich/storetemp2.sh In command prompt it should run, right?
Mraedis
Mraedis•2mo ago
yep
MeshmeZ
MeshmeZOP•2mo ago
how do i check bash version?
Mraedis
Mraedis•2mo ago
I literally posted the command
MeshmeZ
MeshmeZOP•2mo ago
sorry.. until 2 days ago i ddint know what "cron" was... haha
Mraedis
Mraedis•2mo ago
# bash --version
bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# bash --version
bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
MeshmeZ
MeshmeZOP•2mo ago
i have 5.2.15
Mraedis
Mraedis•2mo ago
Really no idea, do you still have the:
/volume1/docker/Immich/storetemp2.sh: line 3: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 4: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 5: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 9: -d: command not found
/volume1/docker/Immich/storetemp2.sh: line 3: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 4: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 5: -H: command not found
/volume1/docker/Immich/storetemp2.sh: line 9: -d: command not found
When running? If yes, your copy/paste is cursed 😛
MeshmeZ
MeshmeZOP•2mo ago
kberliner@DXP2800-2D13:~$ . /volume1/docker/Immich/storetemp2.sh {"message":"Authentication required","error":"Unauthorized","statusCode":401,"correlationId":"s0vkjxqw"}curl: (3) URL using bad/illegal format or missing URL bash: -H: command not found bash: -H: command not found bash: -H: command not found bash: -d: command not found
Mraedis
Mraedis•2mo ago
seriously do cat /volume1/docker/Immich/storetemp2.sh and just don't paste the line with the api key
MeshmeZ
MeshmeZOP•2mo ago
#!/bin/bash curl -L -X PUT 'http://192.168.0.37:2283/api/jobs/storageTemplateMigration' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'x-api-key: apikey' \ -d '{ "command": "start", "force": false
Mraedis
Mraedis•2mo ago
Just plain cursed 😛
MeshmeZ
MeshmeZOP•2mo ago
haha ok at least im not crazy i have no idea wht im doing. but it seemed like i should be doing the right stuff
Mraedis
Mraedis•2mo ago
Just put it all on one line:
#!/bin/bash
curl -L -X PUT 'http://192.168.0.37:2283/api/jobs/storageTemplateMigration' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'x-api-key: permissionsapikey' -d '{ "command": "start", "force": false }'
#!/bin/bash
curl -L -X PUT 'http://192.168.0.37:2283/api/jobs/storageTemplateMigration' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'x-api-key: permissionsapikey' -d '{ "command": "start", "force": false }'
if that still doesn't work, we call the ghostbusters
MeshmeZ
MeshmeZOP•2mo ago
{"message":"Expected ',' or '}' after property value in JSON at position 22 (line 1 column 23)","error":"Bad Request","statusCode":400}
Mraedis
Mraedis•2mo ago
progress lol
MeshmeZ
MeshmeZOP•2mo ago
haha so now im missing a character?
Mraedis
Mraedis•2mo ago
I guess so 22 so that's probably the json content ah right I edited a missing " it's after start
MeshmeZ
MeshmeZOP•2mo ago
!!!! it worked!!! haha thank you! now to see if i can get it to run from cron ok now what is wrong with my cron..... 41 12 * * * /volume1/docker/Immich/storetemp2.sh does it need to be . / yes it does. it is all working now. thank you very much!!
Mraedis
Mraedis•2mo ago
or bash /volume1/docker/Immich/storetemp2.sh would work

Did you find this page helpful?