When you SSH on, you’re in one container. Home Assistant runs in another container - one with different software, and potentially different volumes connected.
Minor plug for something I wrote. Delete old backups shell command error I had the same issue so I wrote a service that you can trigger in an automation. I have made a custom HACS project that you can use if you would like or just copy the files into the custom_components directory.