From 4c9e3b18306f6fcf3993b2b8a52e35d00782e454 Mon Sep 17 00:00:00 2001 From: Jake Walker Date: Tue, 12 Aug 2025 18:01:51 +0100 Subject: [PATCH] add forget_args var --- README.md | 22 ++++++++++------------ defaults/main.yml | 2 +- templates/restic-backup.service.j2 | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 76b985d..24119e3 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ Each folder has a `path` and an `exclude` property (which defaults to nothing). Each database has a `name` property which will be the name of the restic snapshot (`{{ database.name }}.sql`). They also have a `dump_command` property which is the command to dump the database to stdout (like `mysqldump dbname`). -- `restic_forget`: run `restic forget` as `ExecStartPost` with `--keep-within {{ restic_forget_keep_within }}` (`true`) -- `restic_forget_keep_within`: period of time to use with `--keep-within` (`30d`) +- `restic_forget`: run `restic forget` as `ExecStartPost` (`true`) +- `restic_forget_args`: period of time to keep backups for. args passed to `restic forget` if `restic_forget` is enabled (`--keep-within 30d`) - `restic_prune`: run `restic prune` as `ExecStartPost` (`true`) ### SSH/SFTP backend configuration @@ -70,18 +70,17 @@ You can see the logs of the backup with `journalctl`. (`journalctl -xefu restic- ```yaml --- - - hosts: myhost roles: restic vars: restic_ssh_user: backupuser restic_ssh_hostname: storage-server.infra.tld restic_folders: - - {path: "/srv"} - - {path: "/var/www"} + - { path: "/srv" } + - { path: "/var/www" } restic_databases: - - {name: website, dump_command: sudo -Hiu postgres pg_dump -Fc website} - - {name: website2, dump_command: mysqldump website2} + - { name: website, dump_command: sudo -Hiu postgres pg_dump -Fc website } + - { name: website2, dump_command: mysqldump website2 } restic_password: mysuperduperpassword restic_ssh_private_key: |- -----BEGIN OPENSSH PRIVATE KEY----- @@ -97,7 +96,6 @@ S3 example: ```yaml --- - - hosts: myhost roles: restic vars: @@ -106,11 +104,11 @@ S3 example: restic_aws_access_key_id: xxxxx restic_aws_secret_access_key: xxxxx restic_folders: - - {path: "/srv"} - - {path: "/var/www"} + - { path: "/srv" } + - { path: "/var/www" } restic_databases: - - {name: website, dump_command: sudo -Hiu postgres pg_dump -Fc website} - - {name: website2, dump_command: mysqldump website2} + - { name: website, dump_command: sudo -Hiu postgres pg_dump -Fc website } + - { name: website2, dump_command: mysqldump website2 } restic_password: mysuperduperpassword ``` diff --git a/defaults/main.yml b/defaults/main.yml index 357bce9..111a446 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,7 +14,7 @@ restic_folders: [] restic_databases: [] restic_dump_compression_enabled: false restic_forget: true -restic_forget_keep_within: 30d +restic_forget_args: "--keey-within 30d" restic_prune: true restic_check: true diff --git a/templates/restic-backup.service.j2 b/templates/restic-backup.service.j2 index 6d5e022..25013ea 100644 --- a/templates/restic-backup.service.j2 +++ b/templates/restic-backup.service.j2 @@ -34,7 +34,7 @@ ExecStart=/bin/sh -c "{{ database.dump_command }} {{ '| pigz |' if restic_dump_c {% endfor -%} {% if restic_forget %} -ExecStartPost={{ restic_path }} forget --keep-within {{ restic_forget_keep_within }} +ExecStartPost={{ restic_path }} forget {{ restic_forget_args }} {% endif -%} {% if restic_prune %}