Make sanoid more targeted

This commit is contained in:
Wojciech Kozlowski 2022-11-08 22:40:49 +01:00
parent 2cc62f57ec
commit 5b5e5fce4f
5 changed files with 84 additions and 139 deletions

View File

@ -0,0 +1,9 @@
[rpool/var/lib/{{ ansible_hostname }}/data/pod-{{ service_name }}]
use_template = production
recursive = yes
process_children_only = yes
[hpool/backup/{{ ansible_hostname }}/data/pod-{{ service_name }}]
use_template = backup
recursive = yes
process_children_only = yes

View File

@ -0,0 +1,14 @@
[bpool/BOOT]
use_template = production
recursive = yes
process_children_only = yes
[rpool/ROOT]
use_template = production
recursive = yes
process_children_only = yes
[rpool/home]
use_template = production,home
recursive = yes
process_children_only = yes

View File

@ -0,0 +1,37 @@
[template_home]
hourly = 0
[template_production]
frequently = 0
hourly = 36
daily = 30
monthly = 3
yearly = 0
autosnap = yes
autoprune = yes
[template_backup]
autoprune = yes
frequently = 0
hourly = 30
daily = 90
monthly = 12
yearly = 0
### don't take new snapshots - snapshots on backup
### datasets are replicated in from source, not
### generated locally
autosnap = no
### monitor hourlies and dailies, but don't warn or
### crit until they're over 48h old, since replication
### is typically daily only
hourly_warn = 2880
hourly_crit = 3600
daily_warn = 48
daily_crit = 60
[template_ignore]
autoprune = no
autosnap = no
monitor = no

View File

@ -1,136 +0,0 @@
################################
# This is a sanoid.conf file. #
# It should go in /etc/sanoid. #
################################
## name your backup modules with the path to their ZFS dataset - no leading slash.
#[zpoolname/datasetname]
# # pick one or more templates - they're defined (and editable) below. Comma separated, processed in order.
# # in this example, template_demo's daily value overrides template_production's daily value.
# use_template = production,demo
#
# # if you want to, you can override settings in the template directly inside module definitions like this.
# # in this example, we override the template to only keep 12 hourly and 1 monthly snapshot for this dataset.
# hourly = 12
# monthly = 1
#
## you can also handle datasets recursively.
#[zpoolname/parent]
# use_template = production
# recursive = yes
# # if you want sanoid to manage the child datasets but leave this one alone, set process_children_only.
# process_children_only = yes
#
## you can selectively override settings for child datasets which already fall under a recursive definition.
#[zpoolname/parent/child]
# # child datasets already initialized won't be wiped out, so if you use a new template, it will
# # only override the values already set by the parent template, not replace it completely.
# use_template = demo
# you can also handle datasets recursively in an atomic way without the possibility to override settings for child datasets.
[bpool/BOOT]
use_template = production
recursive = yes
process_children_only = yes
[rpool/ROOT]
use_template = production
recursive = yes
process_children_only = yes
[rpool/home]
use_template = production
recursive = yes
process_children_only = yes
[rpool/var/lib/{{ ansible_hostname }}/data]
use_template = production
recursive = yes
process_children_only = yes
[hpool/backup/{{ ansible_hostname }}/data]
use_template = backup
recursive = yes
process_children_only = yes
#############################
# templates below this line #
#############################
# name your templates template_templatename. you can create your own, and use them in your module definitions above.
[template_demo]
daily = 60
[template_production]
frequently = 0
hourly = 36
daily = 30
monthly = 3
yearly = 0
autosnap = yes
autoprune = yes
[template_backup]
autoprune = yes
frequently = 0
hourly = 30
daily = 90
monthly = 12
yearly = 0
### don't take new snapshots - snapshots on backup
### datasets are replicated in from source, not
### generated locally
autosnap = no
### monitor hourlies and dailies, but don't warn or
### crit until they're over 48h old, since replication
### is typically daily only
hourly_warn = 2880
hourly_crit = 3600
daily_warn = 48
daily_crit = 60
[template_hotspare]
autoprune = yes
frequently = 0
hourly = 30
daily = 90
monthly = 3
yearly = 0
### don't take new snapshots - snapshots on backup
### datasets are replicated in from source, not
### generated locally
autosnap = no
### monitor hourlies and dailies, but don't warn or
### crit until they're over 4h old, since replication
### is typically hourly only
hourly_warn = 4h
hourly_crit = 6h
daily_warn = 2d
daily_crit = 4d
[template_scripts]
### information about the snapshot will be supplied as environment variables,
### see the README.md file for details about what is passed when.
### run script before snapshot
pre_snapshot_script = /path/to/script.sh
### run script after snapshot
post_snapshot_script = /path/to/script.sh
### run script after pruning snapshot
pruning_script = /path/to/script.sh
### don't take an inconsistent snapshot (skip if pre script fails)
#no_inconsistent_snapshot = yes
### run post_snapshot_script when pre_snapshot_script is failing
#force_post_snapshot_script = yes
### limit allowed execution time of scripts before continuing (<= 0: infinite)
script_timeout = 5
[template_ignore]
autoprune = no
autosnap = no
monitor = no

View File

@ -9,9 +9,30 @@
mode: 0755 mode: 0755
- name: Configure sanoid - name: Configure sanoid
template: blockinfile:
src: ./filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid.conf.j2 path: /etc/sanoid/sanoid.conf
dest: /etc/sanoid/sanoid.conf create: yes
insertbefore: "BOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK SYSTEM #"
block: "{{ lookup('file', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-system.conf') }}"
- name: Configure sanoid templates
blockinfile:
path: /etc/sanoid/sanoid.conf
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK TEMPLATES #"
block: "{{ lookup('file', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-templates.conf') }}"
- name: Configure sanoid for services
blockinfile:
path: /etc/sanoid/sanoid.conf
insertbefore: "# BEGIN ANSIBLE MANAGED BLOCK TEMPLATES #"
marker: "# {mark} ANSIBLE MANAGED BLOCK SERVICE {{ service_name }} #"
block: "{{ lookup('template', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-service.conf') }}"
with_items: "{{ host_services }}"
loop_control:
loop_var: service_name
- name: Copy service for {{ ansible_hostname }} data replication - name: Copy service for {{ ansible_hostname }} data replication
template: template: