spot check fails when backup contains symlinks #1050

Closed
opened 2025-04-01 01:50:34 +00:00 by itu7 · 3 comments

What I'm trying to do and why

I am trying to run a spot check on a recently written archive.
The spot check always fails if the backup contains symlinks.

This is part of my config:

checks:
- name: spot
  count_tolerance_percentage: 10
  data_sample_percentage: 1
  data_tolerance_percentage: 0

source_directories:
    - /etc

Steps to reproduce

  1. prepare a backup which contains symlinks
  2. run a spot check: borgmatic check -v2 --only spot
  3. try to compute remote hash of a (non matching) symlink:
# borg list --format '{xxh64} {path}{NL}' ssh://pathtorepo::archivename /etc/rc4.d/S01bluetooth
 etc/rc4.d/S01bluetooth

No hash computed - remote borg is unable to compute the hash of a symlink

Actual behavior

Example log (edited):

server: 2 non-matching spot check hashes
server: Source paths with data not matching the latest archive: /etc/rc4.d/S01bluetooth, /etc/rc6.d/K01plymouth

Inspect some files:

# file /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth
/etc/bash.bashrc:        ASCII text
/etc/rc4.d/S01bluetooth: symbolic link to ../init.d/bluetooth
/etc/rc6.d/K01plymouth:  symbolic link to ../init.d/plymouth
# xxh64sum /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth
1c66874322792f28  /etc/bash.bashrc
c8bbc4d25f80a462  /etc/rc4.d/S01bluetooth
404c258b857434f2  /etc/rc6.d/K01plymouth
# borg list --format '{xxh64} {path}{NL}' ssh://pathtorepo::archivename /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth
1c66874322792f28 etc/bash.bashrc
 etc/rc4.d/S01bluetooth
 etc/rc6.d/K01plymouth

Hash is computed for non-symlink only.

Expected behavior

Spot check should not fail if borg is unable to compute the hash.

Other notes / implementation ideas

Spot check sampling routine should skip symlinks if borg is unable to compute the hash.

borgmatic version

1.9.14

borgmatic installation method

Debian package

Borg version

1.4.0 (local)/1.2.4 (remote)

Python version

2.13.2

Database version (if applicable)

No response

Operating system and version

PRETTY_NAME="Debian GNU/Linux trixie/sid" NAME="Debian GNU/Linux" VERSION_CODENAME=trixie ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

### What I'm trying to do and why I am trying to run a spot check on a recently written archive. The spot check always fails if the backup contains symlinks. This is part of my config: ``` checks: - name: spot count_tolerance_percentage: 10 data_sample_percentage: 1 data_tolerance_percentage: 0 source_directories: - /etc ``` ### Steps to reproduce 1. prepare a backup which contains symlinks 2. run a spot check: `borgmatic check -v2 --only spot` 3. try to compute remote hash of a (non matching) symlink: ``` # borg list --format '{xxh64} {path}{NL}' ssh://pathtorepo::archivename /etc/rc4.d/S01bluetooth etc/rc4.d/S01bluetooth ``` No hash computed - remote borg is unable to compute the hash of a symlink ### Actual behavior Example log (edited): ``` server: 2 non-matching spot check hashes server: Source paths with data not matching the latest archive: /etc/rc4.d/S01bluetooth, /etc/rc6.d/K01plymouth ``` Inspect some files: ``` # file /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth /etc/bash.bashrc: ASCII text /etc/rc4.d/S01bluetooth: symbolic link to ../init.d/bluetooth /etc/rc6.d/K01plymouth: symbolic link to ../init.d/plymouth ``` ``` # xxh64sum /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth 1c66874322792f28 /etc/bash.bashrc c8bbc4d25f80a462 /etc/rc4.d/S01bluetooth 404c258b857434f2 /etc/rc6.d/K01plymouth ``` ``` # borg list --format '{xxh64} {path}{NL}' ssh://pathtorepo::archivename /etc/bash.bashrc /etc/rc4.d/S01bluetooth /etc/rc6.d/K01plymouth 1c66874322792f28 etc/bash.bashrc etc/rc4.d/S01bluetooth etc/rc6.d/K01plymouth ``` Hash is computed for non-symlink only. ### Expected behavior Spot check should not fail if `borg` is unable to compute the hash. ### Other notes / implementation ideas Spot check sampling routine should skip symlinks if `borg` is unable to compute the hash. ### borgmatic version 1.9.14 ### borgmatic installation method Debian package ### Borg version 1.4.0 (local)/1.2.4 (remote) ### Python version 2.13.2 ### Database version (if applicable) _No response_ ### Operating system and version PRETTY_NAME="Debian GNU/Linux trixie/sid" NAME="Debian GNU/Linux" VERSION_CODENAME=trixie ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Owner

Thanks for filing this and providing all the diagnostics! I will look into this when I get the chance.

Thanks for filing this and providing all the diagnostics! I will look into this when I get the chance.
Owner

This is fixed in main and will be part of the next release! I went with a slightly different approach than your suggestion though. The issue with skipping symlinks entirely in the spot check is it doesn't catch a few legitimate failing spot check cases:

  • A symlink present in the source directories that's missing from the archive (or present in the archive but is a plain file there).
  • A symlink present in the archive that's missing from the source directories (or present in the source directories but is a plain file there).

So instead, the fix treats symlinks in the source directories as having empty hashes, thereby matching the empty hashes Borg provides for archive symlinks and addressing the above use cases. More importantly, symlinks within an archive no longer break the spot check.

Thanks again!

This is fixed in main and will be part of the next release! I went with a slightly different approach than your suggestion though. The issue with skipping symlinks entirely in the spot check is it doesn't catch a few legitimate failing spot check cases: - A symlink present in the source directories that's missing from the archive (or present in the archive but is a plain file there). - A symlink present in the archive that's missing from the source directories (or present in the source directories but is a plain file there). So instead, the fix treats symlinks in the source directories as having empty hashes, thereby matching the empty hashes Borg provides for archive symlinks and addressing the above use cases. More importantly, symlinks within an archive no longer break the spot check. Thanks again!
Owner

Released in borgmatic 2.0.0!

Released in borgmatic 2.0.0!
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#1050
No description provided.