Overriding hostname constant doesn't affect default archive_name_format #763
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#763
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
The sample config file has this section at the top:
This implies that if I set a
hostname
constant, everywhere that uses{hostname}
will use it instead of the default value (the actual hostname).Docker containers don't have useful hostnames, so I'm trying to set
hostname
to a different value.Steps to reproduce
Sanitized config:
Actual behavior
{hostname} in the path works fine - The path expands to
ssh://backup-homenas@backups01.example.com/data/backup/homenas/`.However, the
archive_name_format
, which is supposed to default to{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}
, still uses the actual hostname.If I explicitly set the format in my config file:
it works fine.
Expected behavior
The default
archive_name_format
should observe any custom value of the{hostname}
constant.Other notes / implementation ideas
No response
borgmatic version
1.8.3
borgmatic installation method
Docker
ghcr.io/borgmatic-collective/borgmatic:1.8.3
Borg version
1.2.6
Python version
3.11.5
Database version (if applicable)
No response
Operating system and version
Alpine Linux v3.18 Docker container on unRAID host
Thanks for filing this! What's going on here is that, confusingly,
{hostname}
can actually be substituted in two different places:hostname
constant as you did here,{hostname}
will get replaced anywhere it exists explicitly in the config file.hostname
constant and/or there's a default pattern containing{hostname}
that doesn't appear directly in the config file (as is the case witharchive_name_format
), then the actual{hostname}
string gets passed to Borg itself, which applies its own placeholder logic.So one option for solving this discrepancy would be to do a first pass on default patterns like
archive_name_format
to apply borgmatic constants to them before passing them to Borg. Or: A work-around would be to set your own explicitarchive_name_format
.In any case, I'm thinking I should probably change the example quoted to not set a constant named
hostname
, as that's confusing in relation to Borg's built-in placeholders.Let me know your thoughts!
Ahh, I see. Now I understand. In that case, it's confusing that Borgmatic and Borgbackup both use the same syntax for their placeholder tokens.
This seems like a good idea to me.
Yeah. Maybe just having the
{prefix}
example is fine?I did want to illustrate in particular that you could have multiple constants, so I think I'll just change the first example from
hostname
to something else. And in factprefix
is deprecated, so maybe I'll change the second example too. Then I'll document the fact that the two types of placeholders are indeed different. Finally, I'll see if constants can be applied toarchive_name_format
.These changes have been made in main and will be part of the next release! Although I'll note that
archive_name_format
supporting ahostname
constant may already have been done since borgmatic 1.8.5 due to #745. Thanks again for bringing this to my attention!