diff --git a/playbooks/filesystem/yggdrasil/etc/sanoid/sanoid-templates.conf b/playbooks/filesystem/yggdrasil/etc/sanoid/sanoid-templates.conf index b78488b..c33a5d5 100644 --- a/playbooks/filesystem/yggdrasil/etc/sanoid/sanoid-templates.conf +++ b/playbooks/filesystem/yggdrasil/etc/sanoid/sanoid-templates.conf @@ -1,7 +1,7 @@ -[template_home] - hourly = 0 - -[template_production] +# Template for system datasets that are not being backed up anywhere. Snapshots are used to provide +# option for rollback without having to reinstall entire system. If the hardware crashes or becomes +# corrupt reinstalling might be smarter given the fact that hardware will likely be different. +[template_system] frequently = 0 hourly = 36 daily = 30 @@ -10,12 +10,34 @@ autosnap = yes autoprune = yes +# Template for home directories which will use the system template, but they don't change so fast. +[template_home] + hourly = 0 + +# Template for datasets with production data. Unlike system datasets, production datasets are +# expected to be backed up, both to spare local storage as well as a remote location. Therefore, +# snapshots only serve the purpose of providing snapshots for these backups. Otherwise, don't keep +# snapshots as they will just take up space. Applications that need their data versioned will be +# versioning themselves so they only need backups. +[template_production] + frequently = 0 + hourly = 2 + daily = 2 + monthly = 0 + yearly = 0 + autosnap = yes + autoprune = yes + +# Template for backup datasets which also doubles as a hot spare. The assumption is that these +# backup production datasets. In addition to three months of snapshots, keep 36 hourly snapshots for +# quick rollback in case of trouble. No monthly snapshots are kept as that would require the +# production template to produce them. [template_backup] autoprune = yes frequently = 0 - hourly = 30 + hourly = 36 daily = 90 - monthly = 12 + monthly = 0 yearly = 0 ### don't take new snapshots - snapshots on backup diff --git a/playbooks/filesystem/yggdrasil/usr/local/sbin/restic-volume-data b/playbooks/filesystem/yggdrasil/usr/local/sbin/restic-volume-data index aa38dc7..118e5c5 100644 --- a/playbooks/filesystem/yggdrasil/usr/local/sbin/restic-volume-data +++ b/playbooks/filesystem/yggdrasil/usr/local/sbin/restic-volume-data @@ -58,7 +58,7 @@ if __name__ == "__main__": subprocess.run(f"{restic_cmd_base} snapshots || {restic_cmd_base} init", shell=True, check=True) subprocess.run(f"{restic_cmd_base} backup .", shell=True, cwd=backup_path, check=True) - subprocess.run(f"{restic_cmd_base} forget --prune --keep-daily 90 --keep-monthly 12", + subprocess.run(f"{restic_cmd_base} forget --prune --keep-daily 30 --keep-monthly 3", shell=True, check=True) subprocess.run(f"{restic_cmd_base} check", shell=True, check=True) diff --git a/playbooks/tasks/backups/00-zfs-snapshots.d/sanoid.yml b/playbooks/tasks/backups/00-zfs-snapshots.d/sanoid.yml index f54467f..76ab9fb 100644 --- a/playbooks/tasks/backups/00-zfs-snapshots.d/sanoid.yml +++ b/playbooks/tasks/backups/00-zfs-snapshots.d/sanoid.yml @@ -7,17 +7,17 @@ marker: "# {mark} ANSIBLE MANAGED BLOCK SYSTEM #" block: | [bpool/BOOT] - use_template = production + use_template = system recursive = yes process_children_only = yes [rpool/ROOT] - use_template = production + use_template = system recursive = yes process_children_only = yes [rpool/home] - use_template = production,home + use_template = system,home recursive = yes process_children_only = yes