gcobb321 / icloud3_v3

iCloud3 v3, Development Version - This Repo/Version is used for development and testing of new and updated features. It is not the official release of iCloud3 v3, .
MIT License
145 stars 12 forks source link

Can you move Temporary work file outside of config folder. #331

Open andyblac opened 1 week ago

andyblac commented 1 week ago

I use auto-backup integration, and it keep failing to do backups due to iCloud temp file being removed after a backup has started.

2024-09-04 12:00:00.453 ERROR (MainThread) [supervisor.homeassistant.module] Can't backup Home Assistant Core config folder: [Errno 2] No such file or directory: '/data/homeassistant/.storage/icloud3/tmpyf_o9nsu'

So, would it be possible to use a temp folder outside of the config folder structure ie use /tmp/icloud3

Thanks Andrew

gcobb321 commented 1 week ago

The iCloud3 log files are renamed at midnight. Change the time of your backup to a few minutes later (12:15, 1:00, etc,)

andyblac commented 1 week ago

The iCloud3 log files are renamed at midnight. Change the time of your backup to a few minutes later (12:15, 1:00, etc,)

this was 12:00 pm midday. not 00:00 am, it happens at random times during the day, I do a auto-backup every hour. it can be ANY of them that this happens on.

gcobb321 commented 1 week ago

The log file is actually a sublog file of the HA logger module and updated using the HA logger routines. Those routines are probably putting a lock on the file while it is updated and out of my control.

The only think I can think of doing is to change the time of your backup to the middle of the night and use the iCloud3 service calls to pause device tracking while the log is being done and resume tracking when it is finished. Or maybe exclude that file from being backed up. I do not see moving the file to another directory.

I back up my files at night around 10pm using the Home Assistant Google Drive Backup add-on and again locally at 2am using an automation and have not had any issues.

andyblac commented 1 week ago

as I said I do hourly backups, and 95% of the it works fine, but about 2-3 backups a day fail. I'll see of it can ignore files using wildcards /data/homeassistant/.storage/icloud3/tmp*

andyblac commented 1 week ago

nope, unfortunately the integration auto-backup does not allow excluding files.

gcobb321 commented 1 week ago

iCloud3 has no *.tmp files the iCloud3 log files in the /config directory are icloud3-0.log, icloud3-1.log and icloud3-2.log for today, yesterday and the day before. The files in the .storage/icloud3 directory that gets updated a lot is _restorestate (no extension). Is updated whenever a state value of the iCloud3 entities change and is used to restore those values on an HA restart. The _waze_locationhistory.db is a sql file that is updated when tracking is done and stores the time & distance to Home so internet calls do not have to be done when driving to get that info. Could that be the file the sql module is creating a tmp file?

andyblac commented 1 week ago

the files start with tmpy, no idea where this coming from, it looks like when it start the backup the file is there, but by the time it gets to the file to include it in the compress it gone, and why it cause the backup to fail. atm I have no tmpy* files n the folder.