diff --git a/README.md b/README.md index 51d8a31..ccbb064 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ If you want to force the installation, overwrite the binary or update restic, yo - `restic_check`: run `restic check` as `ExecStartPre` if true (`false`) - `restic_default_folders`: a default list of folders that restic will backup (`/etc/`, `/root` and `/var/log`) - `restic_folders`: the list of folder you want to backup +- `restic_dump_compression_enabled`: enable piping to pigz for database dumps Each folder has a `path` and an `exclude` property (which defaults to nothing). The `exclude` property is the literal argument passed to restic (exemple: `--exclude .cache --exclude .local`). diff --git a/defaults/main.yml b/defaults/main.yml index bafb5c7..92f5b9b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,6 +13,7 @@ restic_default_folders: - {path: '/root', exclude: '--exclude .cache --exclude .local'} restic_folders: [] restic_databases: [] +restic_dump_compression_enabled: false restic_forget: true restic_forget_keep_within: 30d restic_prune: true diff --git a/tasks/install.yml b/tasks/install.yml index 8ec96e6..3463a4b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -8,6 +8,10 @@ apt: name: bzip2 +- name: Install pigz (to compress db dumps) + apt: + name: pigz + - name: Download restic get_url: url: 'https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_linux_amd64.bz2' diff --git a/templates/restic-backup.service.j2 b/templates/restic-backup.service.j2 index 30fb152..48301f3 100644 --- a/templates/restic-backup.service.j2 +++ b/templates/restic-backup.service.j2 @@ -25,7 +25,7 @@ ExecStart={{ restic_path }} backup --verbose {{ folder.path }} {{ folder.exclude {% endfor -%} {% for database in restic_databases %} -ExecStart=/bin/sh -c "{{ database.dump_command }} | {{ restic_path }} backup --verbose --stdin --stdin-filename {{ database.name }}.sql" +ExecStart=/bin/sh -c "{{ database.dump_command }} {{ '| pigz |' if restic_dump_compression_enabled else '|' }} {{ restic_path }} backup --verbose --stdin --stdin-filename {{ database.name }}{{ '.sql.gz' if restic_dump_compression_enabled else '.sql' }}" {% endfor -%} {% if restic_forget %}