Commit Graph

44 Commits

Author SHA1 Message Date
Manu
9525ec03be fix: auto-configure ssh_command for non-default SSH keys
When users set a custom borg_ssh_key_name, the role generates the key
but borgmatic wasn't configured to use it. This caused confusing
behavior where the custom key was created but not used for auth.

This change auto-detects when a non-default key name is used and
generates the appropriate ssh_command, while keeping configs clean
for users with default keys.

Closes #133
2026-01-06 15:17:51 +00:00
Manu
bdee5114a6 fix: correct systemd timer reference and enable timer by default
Fixes #143 and #164.

- Fix incorrect timer reference in borgmatic.service.j2
  (backup_normal_repo.timer -> borgmatic.timer)
- Add borgmatic_timer_enabled variable (default: true) to control
  whether the systemd timer is enabled after installation
- Simplify timer management logic in noauto_create_timer_systemd.yml

Previously, the timer was always created but never enabled, causing
users to think backups were running when they weren't. Now the timer
is enabled by default. Users who need manual control can set
borgmatic_timer_enabled: false.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 14:46:21 +00:00
Emiel Molenaar
4cb112712b
Add support for custom configuration for borgmatic (#195)
* Add support for custom configuration for borgmatic
* Restrict borgmatic_custom_config to version 1.8+
2026-01-06 14:43:47 +00:00
Manu
c6dd6f9a70
Merge pull request #185 from aphick/master
Add option to control NoNewPrivileges in borgmatic.service
2026-01-05 13:40:24 +00:00
Manu
63ebe59e70 Merge upstream/master and resolve conflicts
- Incorporate retries and retry_wait options from master
- Adapt new options to both legacy (1.7) and new (1.8+) config formats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 13:20:38 +00:00
Manu
1d16b64d24 Improve borgmatic version handling and fix deprecated options
- Rename templates to version-based naming (config_1.7.yaml.j2)
- Use command module instead of shell for version detection
- Add check_mode: false for version detection task
- Fix deprecated remote_rate_limit → upload_rate_limit for 1.8+

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 13:15:40 +00:00
Leonidas Avdelas
88dc6da60e Add retries and retry-wait
Signed-off-by: Leonidas Avdelas <avdelasleonidas@gmail.com>
2025-11-18 07:18:00 +00:00
Tomas Kopal
c700844f75 Add support for configuration syntax of borgmatic > 1.8.0 2025-10-24 15:12:13 +02:00
aphick
3d5e749ee6 add borgmatic_systemd_nonewprivileges to borgmatic.service.j2 2025-08-18 12:01:19 -07:00
Dirk Sarpe
a960af0cf4 adds keep_within setting to borg_retention_policy
option is available upstream
2025-08-17 18:34:01 +01:00
Nish_
4faab60075 add option borgmatic_unknown_unencrypted_repo_access_is_ok
Signed-off-by: Nish_ <120EE0980@nitrkl.ac.in>
2025-07-09 18:38:43 +01:00
Bert-Jan Fikse
e3397c62f7 fix: use path as key for repositories config 2025-07-09 18:37:16 +01:00
hydrandt
b12f97a11f #180 config.yaml.j2 jinja2 trim_blocks string -> boolean 2025-05-14 01:04:54 +01:00
Matthias Stegmann
320975170d Add option to add flags to borgmatic in cron/systemd-timer job 2025-04-07 16:03:00 +01:00
Aaron
781f1226e7
Fix hook indention. By @Jaffr0 (#168)
Co-authored-by: Aaron Paterson <81300255+Jaff-ro@users.noreply.github.com>
2024-12-16 21:47:45 +00:00
Manu
ed8fe0d345
Indent hook name (#159) 2024-12-09 15:32:39 +00:00
Manu
efa8e5ec7f
fix borgmatic_hooks indention (#155) 2024-10-25 16:32:15 +01:00
kaufe
ad163fec68
Add possibility to overwrite compression (#116)
Co-authored-by: Alexander Kaufmann <akaufman@DESKTOP-K5ID02T.localdomain>
2024-10-18 09:01:21 +01:00
AJ Jordan
84b0030581
Fix malformed config if no passphrase set (#148) 2024-03-12 08:44:43 +00:00
Manu
2f57fce727 Remove deprecated Borgmatic option. 2023-04-05 21:12:32 +01:00
Frank Dornheim
dd960dcf4e
Restructure role, add Systemd timer option. By @conloos (#112)
* add full path

* Update Readme.me: reorder optional Arguments, update cron -> systemd timer

* remove ssh_key_file; change cron to timer

* Removed cronie from package installation because systemd timer is used

* docker.sh - Stops all or selected containers to save the persistent data intact. The containers are started in reverse order

* Created arguments_specs.yml

* Role restructured:
  - if needed creation of a service user incl. creation of the ssh-key,
  - add the ssh key to authorized_keys,
  - auto init of the repos,
  - creation and start of systemd timer and services and
  - installation of the Docker helperscript.

* restructure role add import logic

* cleanup: user backup_user

* - "borg_source_directories" is not longer a required Argument
- add "borg_keys_directory" to load key from Service user during starting borgmatic by sudo

* Add borgmatic_initialization_repo (bool) as option to disable init of repo

* cleanup

* fix ansible-lint errors and warnings

* fix letter turner

* add option: borgmatic_timer

* add:
  - borgmatic_timer_systemd: true
readd:
  - borgmatic_cron_name: "borgmatic"

* - renamed borgmatic_cron_name to borgmatic_timer_cron_name to be more convergent.
- Change recommendations implemented by m3nu so that creation of a timer (systemd or cron) is optional and can be selected via borgmatic_timer.

* Add description to borgmatic_timer_cron_name and borgmatic_timer

* Add variable borg_cron_package to install the cron-packages in case of using timer: cron

* reworked timer install logic

* reworked timer install logic

* Add comments for running backup with service account

* add new parameters for tests

* Switch created to perform the backup as root or service account. If a service account is to be used, it will be created.

* Refactored: Check for ssh-key if not present, genereate them.

* Refactored

* Refactored

* renamed tasks/03_configure.yml to tasks/04_create_links_to_borg_and_borgmatic.yml

* Refactored

* Refactored

* add example for service account

* Update Python version for testing

* No auto init

* Add description to install_backup

* Add description to install_backup

* set coverage back to: m3nu.ansible_role_borgbackup

* The initialization of the repository must be activated and does not take place automatically.

* The initialization of the repository must be activated and does not take place automatically.

* Removed install_backup as var (bool) to prevent that this role run

* Rename backup_ssh_command to borg_ssh_command, tis was a double definition

* Renamed backup_repository to borg_repository and add better explanations

* remove copy ssh-keys and cert parts

* Add comments to borg_ssh_key_file and borg_ssh_key_type

* Set allways the borg_ssh_key_file and borg_ssh_command to load the right ssh-key. Add borg_ssh_key_type to select the key type by user

* Add borg_ssh_key_type

* renamed id_rsa to backup

* generate ssh-keys (backup and backup.pub) and add better explanation

* Print out key if borgmatic_initialization_repo is false

* Remove 'su - {{ borgbackup_user }} -c' to execute the borgmatic by the right user

* Add Check frequency, therefore, we no longer need to distinguish between normal and large repos

* Add link to Article

* renamed backup_ssh_command and backup_ssh_key_file to borg_ssh_command and borg_ssh_key_file

* Removed: borgmatic_initialization_repo

* Removed: borgmatic_initialization_repo

* Removed: borgmatic_initialization_repo

* revert changes

* Add Full Automation

* polishing

* rename backup.timer and bakup.service to borgmatic.timer and borgmatic.service

* remove debug

* Try to find services in ansible_facts

* Forgot to install Cron

* change borg_ssh_key_type to ed25519

* remove conditional checks

* - add hint to using a service user
- renamed: borg_ssh_key_file to borg_ssh_key_file_path
- removed advanced example

* add borg_ssh_key_name, renamed borg_ssh_key_file to borg_ssh_key_file_path

* removed static pointing to ~/.ssh/backup SSH private key

* Add README-Advanced-Examples.md for storing more examples

* Fix test idempotence

* Dont symlink when using distro packages

* Remove old test targets, consistent wording, remove tag

* Remove helper scripts, fix absolute path

* Fix cron job, add assert to prevent duplicate timers

* nit-pick

* Create bin links as root, no borg_ssh_command by default.

* Add breaking changes note to README

---------

Co-authored-by: Manu <manu@snapdragon.cc>
2023-03-28 18:01:12 +01:00
Manu
29d0c5f480
Unify all Borgmatic hooks in one variable (#93) 2022-02-20 14:42:09 +04:00
Manu
bb5b6afd4c
Add RHEL9 support, fix empty exclude option (#92) 2022-02-20 13:56:14 +04:00
Lammert Hellinga
b52efea18e
Add if around exclude options to prevent yaml error. By @Kogelvis (#72) 2021-08-05 12:00:42 +04:00
Manu
aa5f2d5d8d
Prettier default archive timestamps (#61) 2021-02-18 23:58:24 +08:00
Luc Stroobant
a10b655e89
Quote exclude patterns correctly. By @stroobl (#56) 2021-01-17 13:31:46 +08:00
K
e9caa74560
Add options for consistency checks and storage. By @kenayagi (#50)
* borg_remote_rate_limit config
* borg_remote_rate_limit optional argument
* Set default rate_limit to 0 (unlimited)
* additional options for checks and storage
2020-12-24 08:23:33 +08:00
K
613b565716
Add optional argument: remote_rate_limit. By @kenayagi (#47) 2020-12-02 19:56:50 +08:00
Philipp Rintz
ee6f93f71b
Support for multiple repositories. By @p-rintz (#41) 2020-11-18 11:41:57 +08:00
Lukas Leitsch
0a490a3a6f
Add hooks variable to config template. By @lukasleitsch (#40) 2020-11-03 16:43:33 +08:00
Manu
12e8bca74c Limit checks to repository data. 2020-02-25 23:39:54 +08:00
Manu
5c883a734b
Add testing with Molecule/Ansible-lint, undo #9 (#26)
* Add testing with Molecule/Ansible-lint and fix linting errors
* Undo PR #9 for now (sorry)
2020-02-18 00:21:21 +08:00
madhermit
2d8d666633
Update: made the lock_wait optional argument configurable (#24) 2020-02-17 20:41:12 +08:00
Marien Fressinaud
fddfbbdc0b Allow to specify borg remote-path argument (#20)
I'm using a server where both Borg 0.x and 1.x are installed. The `borg`
command use the version 0.x but I need the version 1.x. This option
allows me to override the borg remote path with `borg1`.
2020-01-15 07:59:22 +08:00
madhermit
c1fd4e5c80 Added before and after Borgmatic hooks for errors (#10)
This allows you to use this role to run a number of scripts/commands before and after backup using the hooks provided by borgmatic. See https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/#preparation-and-cleanup-hooks

You can specify multiple commands like so:

    borgmatic_before_backup_command:
        - dump-a-database /to/file.sql
        - echo "`date` - Backup hook doing work!"
2019-10-24 13:07:37 +08:00
madhermit
0fcbef29a9 Allow per-app configurations (#9)
This PR allows for multiple per application borgmatic configurations as per this article: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/
2019-10-24 13:05:19 +08:00
Hunter
bf7df0a181 Update: added retention policy settings to config 2019-07-19 21:52:28 +00:00
Manu
e30ce279c4 Improve Borgmatic cron-job names. 2019-05-15 12:44:10 +08:00
Manu
6787e98f08 Add option to check large repos only on Sunday. 2019-05-01 10:39:07 +08:00
Manu
2d1c5c5300 Merge branch 'master' of https://github.com/borgbase/ansible-role-borgbackup 2019-02-28 18:40:31 +08:00
Manu
3e78fd069d Ensure setuptools is updated, avoid updating too many packages. 2019-02-28 18:40:24 +08:00
Varac
349b41c9b2
Fix ssh_command in config.yaml template 2018-11-19 22:35:40 +01:00
Manu
78c7d3a99b Add 4 new config options. (#2) 2018-10-29 11:50:18 +08:00
Manu
fecacf36d9 initial commit 2018-10-06 20:04:20 +08:00