Feature Request: add option to backup relative paths #431

Closed
opened 2021-07-12 02:56:54 +00:00 by gpanders · 4 comments

What I'm trying to do and why

I use Borgmatic to back up data from a Docker volume. In the borg archive I only want the data inside the Docker volume; however, Borgmatic backs up the files usig absolute paths, so the paths inside the borg archive are, e.g.:

/var/lib/docker/volumes/mydata/_data/foo
/var/lib/docker/volumes/mydata/_data/bar

where what I want is simply:

foo
bar

The only way I've found to do this is to use ./ as the source directory in the Borgmatic configuration and then run Borgmatic in the directory that I want to back up. But this feels extremely fragile (if I ever accidentally run it from the wrong directory I will back up something I didn't intend to) and it also means that I'm not actually specifying the source directory in the Borgmatic config file but rather in the crontab/systemd configuration, so my configuration is split up across the system.

Would it be possible to add a new configuration option e.g. use_relative_paths that will first chdir to the directory listed in source_directories and then back up the files within that directory? Of course this would only work if there is only a single source directory listed.

Thanks for making a great and useful piece of software!

#### What I'm trying to do and why I use Borgmatic to back up data from a Docker volume. In the borg archive I only want the data *inside* the Docker volume; however, Borgmatic backs up the files usig absolute paths, so the paths inside the borg archive are, e.g.: ``` /var/lib/docker/volumes/mydata/_data/foo /var/lib/docker/volumes/mydata/_data/bar ``` where what I want is simply: ``` foo bar ``` The only way I've found to do this is to use `./` as the source directory in the Borgmatic configuration and then run Borgmatic in the directory that I want to back up. But this feels extremely fragile (if I ever accidentally run it from the wrong directory I will back up something I didn't intend to) and it also means that I'm not actually specifying the source directory in the Borgmatic config file but rather in the crontab/systemd configuration, so my configuration is split up across the system. Would it be possible to add a new configuration option e.g. `use_relative_paths` that will first `chdir` to the directory listed in `source_directories` and then back up the files within that directory? Of course this would only work if there is only a single source directory listed. Thanks for making a great and useful piece of software!
Owner

Cool idea.. This isn't a use case I had thought of! Instead of use_relative_paths though, what do you think of an option called something like working_directory that contains a path for borgmatic to change directory to before/after backups? Then, you'd be able to list one source_directories entry as ./ or even multiple source_directories relative paths like foo and bar. My thinking is that this behavior might be a little more intuitive.. But I'm interested in whether it would solve your use case well.

Cool idea.. This isn't a use case I had thought of! Instead of `use_relative_paths` though, what do you think of an option called something like `working_directory` that contains a path for borgmatic to change directory to before/after backups? Then, you'd be able to list one `source_directories` entry as `./` or even multiple `source_directories` relative paths like `foo` and `bar`. My thinking is that this behavior might be a little more intuitive.. But I'm interested in whether it would solve your use case well.
Author

Yes I think a working_directory directive actually makes much more sense and that would still address my use case perfectly.

Yes I think a `working_directory` directive actually makes much more sense and that would still address my use case perfectly.
Owner

Thanks to @fabianschilling, this is now implemented as a new working_directory option. This will be part of the next borgmatic release.

Thanks to @fabianschilling, this is now implemented as a new `working_directory` option. This will be part of the next borgmatic release.
Owner

Released in borgmatic 1.5.24.

Released in borgmatic 1.5.24.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#431
No description provided.