Skip to content

can borg list include folders without files? #9036

@mlapaglia

Description

@mlapaglia

i am trying to create an archive browser that doesn't rely on borg mount. i'd like to get the files and folders at a specific path. i am having trouble creating a pattern that will return folders when they only have folders inside them.

Consider this archive:

borg list qwer::backup-20251003-022114
drwxrwxrwx mlapaglia mlapaglia        0 Fri, 2025-09-05 21:53:18 mnt/c/backup-sources
drwxrwxrwx mlapaglia mlapaglia        0 Tue, 2025-09-02 14:48:04 mnt/c/backup-sources/1990
-rwxrwxrwx mlapaglia mlapaglia 11000310 Tue, 2023-08-15 15:01:14 mnt/backup-sources/1990/FastFoto_0489.tif

i am trying to get only the contents of the root of the repo, in this case /mnt would be the only thing returned.

these have no output:

borg list --json-lines \
  --pattern='+ pp:' \
  --pattern='- re:^[^/]+/.+' \
  qwer::backup-20251003-022114
borg list \
  --pattern '+ pf:mnt/' \
  --pattern '+ re:^mnt/[^/]+$' \
  --pattern '! re:^mnt/[^/]+/' \
  --pattern '- **' \
  qwer::backup-20251003-022114
 borg list --json-lines \
  --pattern='+ sh:mnt/*' \
  --pattern='- sh:mnt/*/*' \
qwer::backup-20251003-022114

when i try this on a folder that has files in it i get results:

  borg list \
  --pattern '+ pf:mnt/' \
  --pattern '+ re:^mnt/c/backup-sources/[^/]+$' \
  --pattern '! re:^mnt/c/backup-sources/[^/]+/' \
  --pattern '- **' \
  qwer::backup-20251003-022114
drwxrwxrwx mlapaglia mlapaglia        0 Tue, 2025-09-02 14:48:04 mnt/c/backup-sources/1990
-rwxrwxrwx mlapaglia mlapaglia 19647677 Mon, 2025-08-25 16:53:46 mnt/c/backup-sources/20250822-1713-13.5676762.mp4
-rwxrwxrwx mlapaglia mlapaglia 541624376 Thu, 2025-08-14 06:01:00 mnt/c/backup-sources/LM-Studio-0.3.23-3-x64.exe
-rwxrwxrwx mlapaglia mlapaglia 205668352 Tue, 2025-09-02 15:48:53 mnt/c/backup-sources/calibre-64bit-8.9.0.msi
-rwxrwxrwx mlapaglia mlapaglia 869341120 Fri, 2025-07-25 18:37:21 mnt/c/backup-sources/577.00-desktop-win10-win11-64bit-international-dch-whql.exe
-rwxrwxrwx mlapaglia mlapaglia 592480176 Mon, 2025-07-28 15:37:05 mnt/c/backup-sources/Docker Desktop Installer.exe
drwxrwxrwx mlapaglia mlapaglia        0 Mon, 2025-09-01 19:54:36 mnt/c/backup-sources/testbackupsource

these output the entire archive

borg list \
  --pattern '+ *' \
  --pattern '- */*' \
  qwer::backup-20251003-022114
borg list --json-lines \
  --pattern='+ pp:mnt' \
  --pattern='- re:^mnt/[^/]+/.+' \
 qwer::backup-20251003-022114

is there a way to do this without traversing the whole archive to build up a virtual structure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions