Implement filesystem snapshotting
Created by: SunilMohanAdapa
I dug up a bit on how to do filesystem level snapshotting using Btrfs and Snapper (snapper.io). Here is an implementation proposal. I am willing to guide anyone with basic knowledge of Python, Django and Plinth in implementing this, so marking as beginner.
- The Snapshot module will be a implemented around the Snapper. Debian package for Snapper is available.
- We will focus initially on the root file system but may change that when mount manager is available.
- When the module is accessed, Snapper should get installed and setup process should run.
- The module will not be enabled by default, this can change in later releases and we will make it enabled by default when the module is mature with the help of proposed setup mechanism.
- During the setup mechanism, Snapper configuration for "/" should be created.
snapper create-config /
- When the page is accessed, it should show a list of current snapshots. For each snapshot, date of the snapshot, description, type, and option to remove/revert to the snapshot should be available.
snapper ls
- When reverting to snapshot call
snapper rollback <number>
with appropriate arguments. Then provide a message that system needs to be rebooted with a reboot button. - When removing call `snapper delete '.
- Provide option to create a new snapshot in the main page. Call
snapper create
with appropriate arguments. - Setup proper cleanup configuration. I believe, Snapper's defaults are just fine here we don't need to do anything. When a new configuration is created, the default will be applied to the configuration. Does all three cleanups. It keeps 10 hourly, 10 weekly, 10 monthly and 10 yearly configurations. Removes empty-pre-post type of snapshots. And limits number snapshots to 50. Cron jobs are run daily for cleanup and hourly for new snapshots.
- Setup snapshotting before and after package installations. This can be done by installing a hook file in apt configuration. As example see
apt-btrfs-snapper
. Or just use it after packaging it. Etckeeper is no longer necessary after this.