HAUser2023
(HAUser2023)
December 24, 2025, 6:21am
1
I’m trying to copy files from a subdir of the /backup dir under Home Assistant OS to a directory on a mounted usb drive.
These are the shell commands:
create directory on mounted drive
mkdir -p /media/DATEN/openccu
copy only the last 3 files
ls -t /backup/openccu | head -n 3 | xargs -I{} cp -f /backup/openccu/{} /media/DATEN/openccu/
delete all files older than 10 days
find /media/DATEN/openccu -type f -mtime +10 -delete
When typing these commands into the HA terminal all works fine.
Calling the script from automation only create the folder on the mounted drive.
What is the problem ?
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 24, 2025, 10:02am
2
HAUser2023:
What is the problem ?
Did you try this integration?
or
mekaneck
(Rick)
December 25, 2025, 10:51am
3
It’s customary to share the YAML for what you’ve tried, along with any errors that appear in your logs.
Since you’re asking us to throw darts while blindfolded, I’m going to guess it’s a directory access issue. See allowlist_external_dirs
1 Like
HAUser2023
(HAUser2023)
December 26, 2025, 5:57pm
4
Yes I tried shell_command in configuration.yaml but that didn’t work like the shell file.
Think It is a problem of the “seeing” the /backup/ directory in terminal or in automations.
The automations part has more restrictions and the /backup dir is not accessible for automations. So I hoped I could solve it with a script file, but it has the same problem.
mekaneck
(Rick)
December 26, 2025, 6:40pm
5
You could try reading the other reply this thread
HAUser2023
(HAUser2023)
December 26, 2025, 7:15pm
6
when using
homeassistant:
allowlist_external_dirs:
- /media
- /backup
I get the error:
Invalid config for ‘homeassistant’ at configuration.yaml, line 49: Not a directory ‘allowlist_external_dirs->1’, got ‘/backup’
So this will not work for /backup
mekaneck
(Rick)
December 26, 2025, 8:15pm
7
Is it not the config subfolder? I run container, and backups is plural, so for me it is /config/backups
I’m not sure what it should be for HAOS
Remember the terminal is not the same environment that an HA shell command executes in.
The HA shell commands execute inside the HA docker container.
Whereas terminal command execute in the shell in HAOS which hosts the docker container.
1 Like
HAUser2023
(HAUser2023)
December 27, 2025, 10:46am
9
It looks like there is no way for me to “see” the /backup dir in automations under HAOS.
I use openccu, that create a backup at midnight in the /backup/openccu dir. It is possible to change the backup path in it, I tried /shares/openccu, but the openccu could not see it.