Glob-Expansion (of source directories) does not work on "working directory" #609
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Hi, it's me again :)
What I'm trying to do and why
I try to use relative paths during backup via
working_directoryfield.Issue: using relative-path globs in
source_directoriesfield are not resolved relative toworking_directorySteps to reproduce
Actual behavior
running
$ sudo borgmatic create --verbosity 2 --dry-runlists the create command with*expanded to a list of all files/folders in current directory (where this command is executed)Partial output:
Additionally I am curious why
/root/.borgmaticis always included in the backup ?Expected behavior
Other notes / implementation ideas
Notes about the
location.source_directoriesfield:I expected
- *to work, but this throws an YAML-parser error:did not find expected alphabetic or numeric characterAdditionally I tried
- ./*which gives the same result as- "*"- resolving relative to current directory instead of working directory.Environment
borgmatic version: 1.4.4
borgmatic installation method: openSUSE package manger
Borg version: 1.2.2
Python version: 3.10.7
operating system and version:
Operating System: openSUSE Tumbleweed 20221026
Kernel Version: 6.0.3-1-default (64-bit)
Additional Note:
The Level-2 output of
borgmatic createhas no info that the relativeworking_directorypath is used.I gues borgmatic simply does a
cdbevore. Maybe include this in Level-2 output.I now have a work-around:
includes all directories and files of
/path/to/work-dirin a relative manner.My initial goal was to only include directories (and files) that do not start with a dot. For this I found the following glob pattern to work:
[!.]*This is how I came up with the simplified example in the original post.
I just noticed: for not having
.*directories/files in the repo I could also simply use the exclude patterns.I apologize for the delay in getting to this. Supporting globs relative to the configured working directory seems like a totally reasonable feature!
Yeah, this is a YAML limitation. You need to quote the asterisk, as you discovered.
Agreed.. This would be a good thing to log!
The short answer is that
~/.borgmaticis included to support backing up database dumps. More info is here: https://torsion.org/borgmatic/docs/how-to/backup-your-databases/I ran into the same issue with.
I would workaround this limitation with specifying the directory without globs as i only use them to workaround another limitation.
My top-level directory to backup is a symbolic link (unraid share using single disk). So defining top-level directory in
source_directoriesresults in only backup the symbolic link.Situation:
Content to backup:
/mnt/user/myshare.In unraid this may be a symbolic link to the actual disk mount.
results in having an archive containing only the symbolic link
myshare.I don't want to open a discussion to how symbolic links should be backed up... In my eyes in general they should as they are. Current behavior. But in this special case of a top-level directory it would make sense to make a exception. In most shells you can append a trailing
/to symbolic links which most of the time works perfect for this exception.Unfortunately this workaround doesn't work with borg/borgmatic.
So a workaround would be:
But this does not work in combination with
working_directoryif you want to "hide" the common location from the backup.results in all directories and files in the working directory of borg/borgmatic instead the defined
working_directory.So in working on this ticket, I, uh, kind of expanded scope. Now
working_directoryapplies to all borgmatic actions, not justcreate. And as part of that work, the original ask in this ticket was also implemented.This will be part of the next release. Thanks to @simon-77 for filing this (and to @spali for weighing in)!
Released in borgmatic 1.9.0!