snapshot: add support for sanoid

This commit is contained in:
Hoang Nguyen 2023-08-18 00:00:00 +07:00
parent 62f28a2c92
commit 3854a5f380
Signed by: folliehiyuki
GPG key ID: B0567C20730E9B11
6 changed files with 51 additions and 3 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021-2022 FollieHiyuki
Copyright (c) 2021-2023 Hoang Nguyen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -6,7 +6,7 @@ Stuff that are planned to be added/changed.
- [ ] /etc/security/access.conf
- [ ] Filesystem snapshot:
- [ ] sanoid / zrepl (rootfs=zfs)
- [ ] zrepl (rootfs=zfs)
- [ ] Root on tmpfs
- [ ] Filesystem backup (I don't have spare hard drives -_- so not supported for now):
- [ ] Local incremental backups (to spare disk)

View file

@ -135,7 +135,6 @@ earlyoom:
auditd_logrotate_daily: false
# Configuration for filesystem snapshot tools ─────────────────────────────────
# NOTE: these are examples to take note of available options
snapper:
- name: home
@ -189,7 +188,23 @@ btrbk:
snapshot_dir: '@snapshots'
subvolumes: ['@']
# See /etc/sanoid/sanoid.defaults.conf file for all config options
sanoid:
templates:
production:
frequent_period: 30
hourly: 16
daily: 8
weekly: 4
monthly: 2
autosnap: 'yes'
autoprune: 'yes'
datasets:
rpool/ALPINE/root:
use_template: production
rpool/ALPINE/home:
use_template: production
frequent_period: 15
zrepl:

View file

@ -29,3 +29,5 @@ internetbrands.com
# Ubuntu's motd script sends way too much information to Canonical
motd.ubuntu.com
*.zip

View file

@ -1 +1,14 @@
---
- name: sanoid | Install sanoid and syncoid packages
community.general.apk:
name: sanoid, syncoid
state: present
# 'sanoid' APK package comes with a 15min cronjob, so we only need to modify the configuration file
- name: sanoid | Create configuration file
template:
src: sanoid.conf.j2
dest: /etc/sanoid/sanoid.conf
mode: '644'
owner: root
group: root

View file

@ -0,0 +1,18 @@
{% for dataset in (sanoid.datasets | dict2items) %}
[{{ dataset.key }}]
{% for option in (dataset.value | dict2items) %}
{{ option.key }} = {{ option.value }}
{% endfor %}
{% endfor %}
#############################
# templates below this line #
#############################
{% for template in (sanoid.templates | dict2items) %}
[template_{{ template.key }}]
{% for option in (template.value | dict2items) %}
{{ option.key }} = {{ option.value }}
{% endfor %}
{% endfor %}