I wasn't sure how to title this, but basically whenever I write to my NFS mount I'd also like to keep a local copy for 48 hours, and mount all this under a normal file system, i.e. my application can't be modified to look into different locations.
My use case is that my security system (Frigate NVR in Docker) creates a new directory every day (e.g. /recordings/2022/12/04
). The directory is mounted from the NAS over NFS. I'd like the current day and past day directories to always be accessible locally, because these are the recordings most likely to be viewed.
What I thought about is using OverlayFS to mount a local copy over the remote current and past day directories, with a directory watcher / cron job to sync the files back to the NAS regularly, and another daily cron job to delete the "expired" local files. But maybe there's a simpler way?