Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run backup create with set +e if pruning is enabled #186

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

bastelfreak
Copy link
Member

@bastelfreak bastelfreak commented Nov 8, 2023

In case a file changes during a backup, borg will log a warning like this:

Nov 07 18:30:05 webserver01 borg-backup[849693]: Creating archive at "backup:webserver01::backup-20231107-183001"
Nov 07 18:30:42 webserver01 borg-backup[849693]: /var/lib/postgresql/16/main/pg_wal/00000001000000010000004E: file changed while we backed it up
Nov 07 18:30:59 webserver01 borg-backup[849693]: /var/lib/fail2ban/fail2ban.sqlite3: file changed while we backed it up

It will finish the backup, but the exit code will be 1. Because of the set -e at the top, the script will exit. If manage_prune is true, a prune command is configured. It won't be executed when a file change during a backup.

We now add || true to the backup create command.

@bastelfreak bastelfreak self-assigned this Nov 8, 2023
@bastelfreak bastelfreak added the enhancement New feature or request label Nov 8, 2023
@jay7x
Copy link
Member

jay7x commented Nov 8, 2023

set -e can be worked around with borg ... || true FYI.. so maybe you can consider this also

@kenyon
Copy link
Member

kenyon commented Nov 8, 2023

The way @jay7x mentions should make it easier to not duplicate the whole command line as well. Just put the || true part in the conditional.

@bastelfreak
Copy link
Member Author

@kenyon @jay7x updated it

templates/borg-backup.sh.epp Outdated Show resolved Hide resolved
In case a file changes during a backup, borg will log a warning like
this:
```
Nov 07 18:30:05 webserver01 borg-backup[849693]: Creating archive at "backup:webserver01::backup-20231107-183001"
Nov 07 18:30:42 webserver01 borg-backup[849693]: /var/lib/postgresql/16/main/pg_wal/00000001000000010000004E: file changed while we backed it up
Nov 07 18:30:59 webserver01 borg-backup[849693]: /var/lib/fail2ban/fail2ban.sqlite3: file changed while we backed it up
```

It will finish the backup, but the exit code will be 1. Because of the
set -e at the top, the script will exit. If manage_prune is true, a
prune command is configured. It won't be executed when a file change
during a backup.

We now add `|| true` to the backup create command.
spec/classes/init_spec.rb Outdated Show resolved Hide resolved
@bastelfreak bastelfreak merged commit e7095f8 into voxpupuli:master Nov 9, 2023
19 checks passed
@bastelfreak bastelfreak deleted the set branch November 9, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants