pssc / ha-addon-lms

Logitech Media Server Addon for Home Assistant
GNU General Public License v3.0
56 stars 13 forks source link

cache folder is included in home assistant backup #11

Closed jesperll closed 1 year ago

jesperll commented 2 years ago

Thanks for the great addon! I noticed that the cache folder is placed under the home assistant config folder which causes it to be included in backups. I tried relocating it using the configuration settings but couldn't get it to work. Looking at some other addons it seems the best place to store stuff that shouldn't be backed up is under /data so I think changing ENV LMS_CACHE /config/lms/cache to ENV LMS_CACHE /data/cache would mean that the cache would no longer be included in the full backup

pssc commented 2 years ago

Hi no in a full backup /data will be backed up in all the addon's.

/data/mnt/... is unbacked up I have excluded it in the add config so try there.

Phill.

On Fri, 28 Jan 2022 at 08:54, Jesper Larsen-Ledet @.***> wrote:

Thanks for the great addon! I noticed that the cache folder is placed under the home assistant config folder which causes it to be included in backups. I tried relocating it using the configuration settings but couldn't get it to work. Looking at some other addons it seems the best place to store stuff that shouldn't be backed up is under /data so I think changing ENV LMS_CACHE /config/lms/cache to ENV LMS_CACHE /data/cache would mean that the cache would no longer be included in the full backup

— Reply to this email directly, view it on GitHub https://github.com/pssc/ha-addon-lms/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANORYLGJXLQF2R4XNVQ5E3UYJKVZANCNFSM5NAFK23A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- I Can Resist Everything Except Temptation -- Oscar Wilde

jesperll commented 2 years ago

Ah ok. Learning more and more about the structure of addons :)

How would I make the lms addon store its cache in that folder? Or maybe just part of it. I would specifically like to avoid /config/lms/cache/spotty being stored anywhere where HA will back it up (It's currently 1.4GB of temporary files that just makes the backup process slower and takes up space on my disk)

Is this something that can be done through the links/mounts/dirs in the settings?

pssc commented 2 years ago

@jesperll /data/mnt/... is not backed up so you could create a dir in there and link /config/lms/cache/spotty to it.

ovizii commented 2 years ago

@jesperll /data/mnt/... is not backed up so you could create a dir in there and link /config/lms/cache/spotty to it.

I'm struggling with your examples for links, dirs, mounts. would you please give an example on how one do this?

So far I have figured out how to create two folders: image

What would I enter into the links editor. Does this look right? image

Gave it a try and ended up with an error:

[cont-init.d] 15-ha-mounts.sh: exited 0.
[cont-init.d] 17-ha-links.sh: executing... 
ln: failed to create symbolic link '/config/lms/cache/cache': File exists

btw it looked like it worked, I only got this error after the second lms restart :-/

then I thought, hey lets remove the links and ended up with this mess: image

pssc commented 2 years ago

@ovizii Yes as the link already exits as it created it last time have a look in the terminal ls -la /config/lms/cache /config/lms/cache/cache. I take it in then bails due to the error?

ovizii commented 2 years ago

YES!

Sorry for the confusion, not sure if it's me or these instructions, but things are very unclear (to me at least).

I assumed I add a CIFS share to mount into a directory which needs to be created inside this add-on first (see my screenshots above). I thought “links” is basically just like a folder being mounted via docker into the container i.e., the folder /data/mnt/music created inside this add-on and then the CIFS share is mounted to this folder.

Similar I assumed the folder /data/mnt/cache will be created inside the add-on and the cache pointed there.

But if I read you correctly, I am totally wrong.

Would you please shed some light onto this issue? Can you give me some tips to straighten things out according to what I am trying to accomplish here?

All I want is to access my music via a CIFS share and make sure the music folder as well as any cache folders do not get backed up via the home assistant snapshots.

pssc commented 2 years ago

@ovizii this all looks ok on the surface and I understand what your trying to-do, could i see the output from ls and I will go away and prod a test system,

pssc commented 2 years ago

@ovizii hmmm try stopping the addon delete the cache dir and start again with the link config in place see if that solves the problem. I think the issue here is that /config/lms/cache pre-existed as a dir hence ln has created /config/lms/cache/cache

ovizii commented 2 years ago

Here you go:

ls -al /config/lms/cache                                                                                                                        
total 131276                                                                                                                                         
drwxr-xr-x    8 ovi      root          4096 Jun 13 09:34 .                                                                                           
drwxr-xr-x    7 root     root          4096 Jun 13 09:02 ..                                                                                          
drwxr-xr-x    2 ovi      nobody        4096 Jun 13 09:18 DownloadedPlugins                                                                           
drwxr-xr-x    3 ovi      nobody        4096 Jun 13 09:18 InstalledPlugins                                                                            
-rw-r--r--    1 ovi      nobody       53248 Jun 13 09:24 artwork.db                                                                                  
drwxr-xr-x    2 ovi      nobody        4096 Jun 13 09:02 audioUploads                                                                                
lrwxrwxrwx    1 root     root            15 Jun 13 09:24 cache -> /data/mnt/cache                                                                    
-rw-r--r--    1 ovi      nobody      610304 Jun 13 09:24 cache.db                                                                                    
-rw-r--r--    1 ovi      nobody       32768 Jun 13 09:27 cache.db-shm                                                                                
-rw-r--r--    1 ovi      nobody      523272 Jun 13 09:27 cache.db-wal                                                                                
-rw-r--r--    1 ovi      nobody         388 Jun 13 09:34 cookies.dat                                                                                 
-rw-r--r--    1 ovi      nobody        1392 Jun 13 09:18 extrastrings.json                                                                           
-rw-r--r--    1 ovi      nobody       16384 Jun 13 09:05 imgproxy.db                                                                                 
-rw-r--r--    1 ovi      nobody         731 Jun 13 09:02 infobrowser.opml                                                                            
-rw-r--r--    1 ovi      nobody         165 Jun 13 09:02 infobrowser.opml.backup                                                                     
-rw-r--r--    1 ovi      nobody    41455616 Jun 13 09:34 library.db                                                                                  
-rw-r--r--    1 ovi      nobody       98304 Jun 13 09:34 library.db-shm                                                                              
-rw-r--r--    1 ovi      nobody    43045792 Jun 13 09:34 library.db-wal                                                                              
-rw-r--r--    1 ovi      nobody     6664192 Jun 13 09:32 persist.db                                                                                  
-rw-r--r--    1 ovi      nobody       98304 Jun 13 09:34 persist.db-shm                                                                              
-rw-r--r--    1 ovi      nobody    41566712 Jun 13 09:34 persist.db-wal                                                                              
-rw-r--r--    1 ovi      nobody       27657 Jun 13 09:18 plugin-data.yaml                                                                            
-rw-r--r--    1 ovi      nobody      161229 Jun 13 09:18 stringcache.x86_64-linux.bin                                                                
drwxr-xr-x    4 ovi      nobody        4096 Jun 13 09:20 templates                                                                                   
drwxr-xr-x    2 ovi      root          4096 Jun 13 09:02 tmp                                                                                         
drwxr-xr-x    2 ovi      nobody        4096 Jun 13 09:02 updates                      
ls -al /config/lms/cache/cache                                                                                                                  
lrwxrwxrwx    1 root     root            15 Jun 13 09:24 /config/lms/cache/cache -> /data/mnt/cache

btw. I see this symlink: cache -> /data/mnt/cache but there is no folder mnt inside /data

Thanks for taking the time to help me figure out what I messed up here.

ovizii commented 2 years ago

@ovizii hmmm try stopping the addon delete the cache dir and start again with the link config in place see if that solves the problem. I think the issue here is that /config/lms/cache pre-existed as a dir hence ln has created /config/lms/cache/cache

OK lets see how this goes. I have now deleted rm -rf /config/lms/cache and will start your add-on again with the exact same settings posted above and see what happens.

Started just fine, the file system looks like this:

ls -al /config/lms                                                                                                                              
total 24                                                                                                                                             
drwxr-xr-x    6 root     root          4096 Jun 14 23:00 .                                                                                           
drwxr-xr-x   12 root     root          4096 Jun 14 08:20 ..                                                                                          
drwxr-xr-x    2 ovi      root          4096 Jun 13 09:02 addon                                                                                       
lrwxrwxrwx    1 root     root            15 Jun 14 23:00 cache -> /data/mnt/cache                                                                    
drwxr-xr-x    2 ovi      root          4096 Jun 14 23:00 logs                                                                                        
drwxr-xr-x    2 ovi      root          4096 Jun 13 09:02 plugins                                                                                     
drwxr-xr-x    3 ovi      root          4096 Jun 14 23:00 prefs                                                                                       
➜  ~ ls -al /data/mnt/cache                                                                                                                          
ls: /data/mnt/cache: No such file or directory       

I stopped the add-on, restarted saw this in the log file:

Start Logitech Media Server...
[services.d] done.
[23:02:57] INFO: Waiting for lms before starting NGinx...
[23:02:58] INFO: Starting NGinx...
error: ClientConnectorError: Cannot connect to host homeassistant.local:8123 ssl:default [No address associated with hostname]
Run with -x to see full exception information
[23:03:06] INFO: Event lms.service
{"entity_id":"binary_sensor.entity_state_cli_test","state":"on","attributes":{},"last_changed":"2022-06-14T21:00:23.301930+00:00","last_updated":"2022-06-14T21:00:23.301930+00:00","context":{"id":"01G5J08XW5VVJY9HV9471N50M6","parent_id":null,"user_id":"427f341dbfb5439c817d98a5223b00fd"}}
{"message": "Event lms.service fired."}
[23:03:06] INFO: Starting the Home Assistant STDIN service for lms...

now I have figured out how to trigger the problem: as soon as I type "material" into the skin config section and restart it seems lms wants to actually write something into the cache folder and the logs show:

[cont-init.d] 11-ha-dirs.sh: executing... 
mkhadir /data/mnt/music
mkhadir /data/mnt/cache
[cont-init.d] 11-ha-dirs.sh: exited 0.
[cont-init.d] 15-ha-mounts.sh: executing... 
mount -v -t cifs -o user=myuser,pass=mypass //10.10.10.10/music /data/mnt/music
mount.cifs kernel mount options: ip=10.10.10.10,unc=\\10.10.10.10\music,user=myuser,pass=********
[cont-init.d] 15-ha-mounts.sh: exited 0.
[cont-init.d] 17-ha-links.sh: executing... 
ln: failed to create symbolic link '/config/lms/cache/cache': File exists
[cont-init.d] 17-ha-links.sh: exited 1.
ovizii commented 2 years ago

btw. when accessing lms interface I get:

404 Not Found:
There is no "material" skin, try http://10.10.10.87:9000 instead.

and then the add-on might have crashed my HA instance or its at terrible coincidence as HA became inaccessible and when I accessed the vm's console I saw: waiting for supervisor to startup :-)

Anyway, don't worry about that. The problem is now back at the start with ln: failed to create symbolic link '/config/lms/cache/cache': File exists

pssc commented 2 years ago

@ovizii yup ok so bear in mind in the terminal app unless you have used docker exec to enter the container you viewing the private /data of that addon ie in this case the terminal app not lms.

ok work round to add to init commands add rm -rf /config/lms/cache/cache also stop the add run that command in the terminal app and start addon again.

A side effect of deleting the cache is no lms addon's will be installed hence no material skin.

I think I now understand all the issues here

ovizii commented 2 years ago

I think I now understand all the issues here

I'm glad you do as I am totally confused. I didn't enter the docker container as you didn't mention I should do that.

Do you have other ideas to fix this in the future or is this workaround the final solution? Or am I simply doing something stupid here, trying to bend your add-on in ways it wasn't meant to be bent?

pssc commented 2 years ago

@ovizii that all right bear in mind I have 25+ years of unix admin to call upon, this should be totally doable.

So the workaround should do it from what I have seen so far. This is due to the links only really being intended for the non-permeant store filesystems in the container but here of course the link is persisting. In fact i think i tested this manually(putting in the link manually in the terminal addon rather than using config) for @jesperll at the time, but that's more the two sleeps ago now so its a little fuzzy.

ovizii commented 2 years ago

@pssc I don't doubt you and really appreciate the fact that someone created this add-on in his spare time and even takes time to support other people figuring it out.

I've implemented your workaround.

ovizii commented 2 years ago

with your workaround, should the material theme work? If I try I still get:

404 Not Found:
There is no "material" skin, try http://10.10.10.87:9000 instead.

when visiting lms

pssc commented 2 years ago

@ovizii have you reinstalled it in the plugins in lms?

ovizii commented 2 years ago

No, I did not as your instructions didn't mention anything about needing a plugin to get the material skin :-) I'm a total lms newbie so I just blindly followed the instructions here: https://github.com/pssc/ha-addon-lms/blob/master/lms/DOCS.md

Maybe you should just add a sentence to mention that to use this feature you need to first activate a certain plugin.

image

I'm also wondering why I would do it this way and activate a plugin ,restart lms, then edit the config to use the material skin when I can just activate the plugin and set the skin via settings, then reboot? image

I'm just thinking out loud, maybe there's a deeper reasoning behind which is obvious for more seasoned users of lms.

Anyway, I activated the material plugin, restarted lms, changed the skin via its settings, got asked to refresh my browser which I did and then lms turned to a blank page.

The logs said this:

image

Upon restarting, lms keeps showing me a blank page. The logs are silent with no errors. image

image

I only managed to get lms back up and running after adding this back into its config: image

ovizii commented 2 years ago

We can safely close this issue, I just don't have a button to do so. Thanks for your patience.

pssc commented 2 years ago

@ovizii so you all sorted and working ? I take your point about the documentation is work mentioning fore newer people that the material skin is an lms plguin that need to be installed.

ovizii commented 2 years ago

Thanks, all solved except I gave up on the material skin and to my embarrassment I only now realized I had completely hijacked this thread. I promised to do better from now on. :-(

pssc commented 2 years ago

@ovizii if you still having issues with getting the material skin working please log another issue and we can work on it there

mohankumargupta commented 2 years ago

This config works for me, for what its worth.

addon config

However, when I take a Full Backup in HA, the addon's /data/mnt/cache is still included in the backup, hence the reason for the PR.

mohankumargupta commented 2 years ago

Hi no in a full backup /data will be backed up in all the addon's. /data/mnt/... is unbacked up I have excluded it in the add config so try there. Phill.

Although the addon's current config.json has "backup_exclude": [ "/data/music", "/data/mount", "/data/mnt" ]

For me , if there is content inside /data/mnt, then it will be included in the addon's backup, which is not really an issue unless you take a HA full backup which includes the addon backup as well.

pssc commented 2 years ago

@mohankumargupta this is not expected behaviour, I will have a look

pssc commented 1 year ago

@mohankumargupta I can confirm the issue and I have a fix in testing

pssc commented 1 year ago

"backup_exclude": [ "./lms/music/**", "./lms/mnt/**", "./lms/notbackedup/**", "./lms/test/*", "*/nobackup/*" ], So under the /data/lms/notbackedup is not backed up... or under any dir called nobackup, from >=0.53