Bash-style include patterns for source_directories #637

Closed
opened 2023-02-09 15:43:30 +00:00 by persal · 2 comments

What I'm trying to do and why

We want to make sure no "bak" directories are included in the backup. Having convention for exclude_pattern exist, but if some users do not follow the naming convention, it will of course be backed up. This is what we want to avoid.

So instead, we try to narrow down exactly what to backup. Is it possible to describe folders with bash-expansion {..} or similar?

Lets say we want to backup somedir/year/month/day/* paths:

/data/node_data/*/2023/01/01/*
...
/data/node_data/*/2023/12/31/*

And we want to make sure to exclude paths like:

/data/node_data/*/2023/01.bak/31/*
/data/node_data/*/2023/01.somename/31/*
/data/node_data/*/2023/tmpdir123/31/*

source_directories could look like:

/data/node_data/*/2023/{01,02,03,04,05,06,07,08,09,10,11,12}/{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}/*

Or even better:

/data/node_data/*/2023/{01..12}/{01..31}/*

Is this possible?

I have tried using the
"patterns" with regex and + and - but find it having quite strang behavior.

Environment

borgmatic version: 1.5.24
Borg version: 1.2.0
Python version: 3.9.2
operating system and version: Debian 11

#### What I'm trying to do and why We want to make sure no "bak" directories are included in the backup. Having convention for exclude_pattern exist, but if some users do not follow the naming convention, it will of course be backed up. This is what we want to avoid. So instead, we try to narrow down exactly what to backup. Is it possible to describe folders with bash-expansion {..} or similar? Lets say we want to backup `somedir/year/month/day/*` paths: ``` /data/node_data/*/2023/01/01/* ... /data/node_data/*/2023/12/31/* ``` And we want to make sure to exclude paths like: ``` /data/node_data/*/2023/01.bak/31/* /data/node_data/*/2023/01.somename/31/* /data/node_data/*/2023/tmpdir123/31/* ``` source_directories could look like: ``` /data/node_data/*/2023/{01,02,03,04,05,06,07,08,09,10,11,12}/{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}/* ``` Or even better: ``` /data/node_data/*/2023/{01..12}/{01..31}/* ``` Is this possible? I have tried using the "patterns" with regex and + and - but find it having quite strang behavior. #### Environment **borgmatic version:** 1.5.24 **Borg version:** 1.2.0 **Python version:** 3.9.2 **operating system and version:** Debian 11
Owner

I don't believe what you're trying to do is currently possible with source_directories, as that only expands simple globs (*) and tildes (~). For anything more complex, you'll need to use patterns, which includes support for regexes, shell-style expressions, etc. Perhaps you can post what you've tried so far with patterns and describe how it's not working? I'd be happy to help debug.

I don't believe what you're trying to do is *currently* possible with `source_directories`, as that only expands simple globs (`*`) and tildes (`~`). For anything more complex, you'll need to use `patterns`, which [includes support for regexes, shell-style expressions, etc.](https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-patterns) Perhaps you can post what you've tried so far with patterns and describe how it's not working? I'd be happy to help debug.
witten added the
question / support
label 2023-02-09 17:10:20 +00:00
Owner

Closing this for now, but please feel free to follow up and/or reopen so we can continue discussing. Thanks!

Closing this for now, but please feel free to follow up and/or reopen so we can continue discussing. Thanks!
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#637
No description provided.