I would like to be able to merge changes from the upper filesystem of an overlay mount to a lower filesystem.
I am interested both online (i.e. merge while the overlay is mounted) and offline (unmount the overlay and then merge) solutions.
I have found a couple of offline solutions, which I have added as answers.
Does anyone know of any online solutions? It would be good to have a "commit" type command you could run to merge down the layers while the overlay is still mounted.
Something like this has been asked in the following questions with no answer:
- Is there anyway to modify one file and sync to the lower directory in OverlayFs?
- How to modify a lower file through an OverlayFS directory?
- OverlayFS Seamlessly Edit File in Lower Directory
- OverlayFS - How to make changes to upper filesystem persistent without unmounting?
Comments in these posts suggest variously mergerfs and bcache, both of which solve specific use cases but not the generic filesytem-agnostic use case that overlays provide.
My goal is to have a safe filesystem sandbox with snapshots that can be used with any Linux application over any (where practical) underlying filesystem, allowing you to roll back changes or manually commit them when you are ready.
I have a suspicion that modern mainline Linux has all the necessary features to do this built-in, thanks to all the sandboxing/virtualization innovations of the last few years, if only I knew how to use them.
rsync -a --delete merged/ lower/
to replicate what is seen inside the overlayfs mountpoint to the lower directory ? Obviously it would be an offline solution, as it's not atomic. But it seems easier than rdiffdir, so I might be missing something.overlayfs
to protect it and sync down to lower judiciously