Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: lvm: Add lvm-based backup functionality #78

Merged
merged 4 commits into from
Aug 10, 2023

Conversation

Hurricos
Copy link
Contributor

This series implements the needs of #75 through the use of LVM snapshots + mount namespaces.

It's a WIP at this point, as both the implementation and documentation around it need cleanup.

This commit implements the needs of roles-ansible#75[^1]: it allows for the
creation of atomic backups when the backup target is a file/dir whose
fs rests on LVM. This ensures the snapshot will be atomic.

By using a mount namespace, the LVM snapshot can be done in the same
directory -- so existing LVM-based applications of ansible_role_restic
can be migrated to this implementation without any discontinuity in
what appears to be backed up.

This combination of LVM's snapshotting layer and mount namespaces
comes with some caveats:

- you cannot backup / due to namespace issues
- subdirs with a separate fs won't be correctly detected
- not all filesystems are happy about LVM snapshots -- btrfs, e.g.
- LVM snapshots come with a performance penalty when active
- fstrim and LVM snapshots don't like each other whatsoever

[^1]: roles-ansible#75

--
Changes in v2:
- Use `findmnt -v` to find snapshot when cleaning up
- Check for _snap before `lvremove -y`

Signed-off-by: Martin Kennedy <[email protected]>
Grr! this is really frustrating. We need more "tracking" for the
snapshot we created.
This commit causes an LVM backup target of / to be treated as /rootfs
instead.

Note that this will conflict with a path called /rootfs if we *do* try
to back that up.

Also, while we're at it, drop the -m option from mount. Not all
systems have this option.
Before this commit, since restic backup exits with status 3 if it
cannot read one or more files, the LVM snapshot wasn't being cleaned
up.

Now, specially handle the 3 exit status; also, unequivocally perform
the LVM cleanup when finished.
@DO1JLR
Copy link
Member

DO1JLR commented Aug 10, 2023

tanks

@DO1JLR DO1JLR merged commit 7ec0667 into roles-ansible:main Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants