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
: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.Do you have the "Sync Albums" setting set on your phone
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?
Is this for items that are uploaded in the background?
yes.
I think it's a current limitation of the background upload but not 100% sure
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
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
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?
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
ahh... i see... now that i have opened the app it has tagged the file correctly, and the migration does move the file
Correct
So it's a race condition currently
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.
Unfortunatley if you don't know how to call the api on a schedule, you will manually have to do it right now
and in the mean time, my files are still being automatically backed up, just not filed how i want them
Yep, open bug
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?
Immich API
Immich API Documentation
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
}'
I can take a look at this a little later
thank you!
Is the script even running? Whats the output when you run it manually? Theres a lot of debugging you can do here
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
I think you simply have a typo somewhere in your script @MeshmeZ
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
I did too, literally
are you sure you're not missing the \ at the end
i am. ill try it
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
do you mean do this:
-d '{"command": "start","force": false}'\
instead of this? -d '{
"command": "start",
"force": false
}'
No

#!/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
}'
all looks fine to me...
and to make sure im not soing something silly... this is in a .sh file
yes
the file extension doesn't actually matter though

bash --version maybe your bash is ancientso if i run
chmod +x /volume1/docker/Immich/storetemp2.sh
and then
. /volume1/docker/Immich/storetemp2.sh
In command prompt it should run, right?
yep
how do i check bash version?
I literally posted the command
sorry.. until 2 days ago i ddint know what "cron" was... haha
i have 5.2.15
Really no idea, do you still have the:
When running?
If yes, your copy/paste is cursed 😛
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
seriously do
cat /volume1/docker/Immich/storetemp2.sh and just don't paste the line with the api key#!/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
Just plain cursed 😛
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
Just put it all on one line:
if that still doesn't work, we call the ghostbusters
{"message":"Expected ',' or '}' after property value in JSON at position 22 (line 1 column 23)","error":"Bad Request","statusCode":400}
progress lol
haha
so now im missing a character?
I guess so
22 so that's probably the json content
ah right I edited a missing "
it's after start
!!!! 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!!
or bash /volume1/docker/Immich/storetemp2.sh would work