Backup problem AttributeError: ‘NoneType’ object has no attribute ‘name’

OMD[cmk]:~$ omd backup /tmp/cmk-backup.10.06.2026bis.tar.gz
Traceback (most recent call last):
File “/omd/sites/cmk/bin/omd”, line 54, in
omdlib.main.main()
~~~~~~~~~~~~~~~~^^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/main.py”, line 3343, in main
_run_command(command, site, global_opts, args, options)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/main.py”, line 3305, in _run_command
omdlib.backup.main_backup(object(), site, global_opts, args, command_options)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 116, in main_backup
returncode = main_site_backup(backup_args)
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 126, in main_site_backup
_try_backup_site_to_tarfile(tar, BackupExclusions.from_args(args), site, args.verbose)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 60, in _try_backup_site_to_tarfile
_backup_site_to_tarfile(
~~~~~~~~~~~~~~~~~~~~~~~^
site.name,
^^^^^^^^^^
…<4 lines>…
verbose,
^^^^^^^^
)
^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 173, in _backup_site_to_tarfile
_tar_add(
~~~~~~~~^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 400, in _tar_add
_tar_add( # recursive call
~~~~~~~~^^^^^^^^^^^^^^^^^^^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 400, in _tar_add
_tar_add( # recursive call
~~~~~~~~^^^^^^^^^^^^^^^^^^^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 371, in _tar_add
if not predicate(tarinfo):
~~~~~~~~~^^^^^^^^^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 155, in accepted_files
return not any(
~~~^
fnmatch.fnmatch(tarinfo.name[len(site_name) + 1 :], glob_pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
for glob_pattern in excludes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p5.community/lib/python3/omdlib/backup.py”, line 156, in
fnmatch.fnmatch(tarinfo.name[len(site_name) + 1 :], glob_pattern)
^^^^^^^^^^^^
AttributeError: ‘NoneType’ object has no attribute ‘name’

Same root cause here, different trigger and the regression is easy to pinpoint.

Diffed omdlib/backup.py between v2.4.0 and v2.5.0p6:

tarinfo = tar.gettarinfo(name, arcname)
  • if tarinfo is None or not predicate(tarinfo): # 2.4.0

  • if not predicate(tarinfo): # 2.5.0p6
    return

The tarinfo is None guard was dropped between 2.4 and 2.5 — likely a casualty of
the refactor that introduced BackupExclusions as a dataclass and renamed
tar_add_tar_add.

tarfile.gettarinfo() returns None for file types tarfile can’t represent —
most importantly Unix sockets (S_ISSOCK). Without the guard, predicate(None)
explodes in accepted_files at tarinfo.name[...].

In our case the trigger were stale OpenSSH ControlMaster sockets in
~/.ssh/control-* (the site fetches agents over SSH and the ControlPath points
at the site home). 2.4 silently skipped them, 2.5 crashes the whole backup.

WATO exposes no custom-exclude field in the backup job, only the
rrds/agents/logs toggles, so we can’t work around this from the UI. We resorted to hotpatching by doing

sed -i 's|            if not predicate(tarinfo):|            if tarinfo is None or not predicate(tarinfo):|' /omd/versions/2.5.0p6.pro/lib/python3/omdlib/backup.py

Looks like a clear regression, could the Checkmk team please look at this?
Restoring the tarinfo is None or part should be enough.

The bug is still present in 2.5.0p12.community.

Thanks @micvog for the patch, I’ll apply it after each update until it gets fixed upstream.

Hi Michael,
With your solution, the backup was working until yesterday.

Then yesterday I updated to version 13, made the change to the backup.py file again, but it throws an error with the following message:

Traceback (most recent call last):
File “/omd/sites/cmk/bin/omd”, line 54, in
omdlib.main.main()
~~~~~~~~~~~~~~~~^^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/main.py”, line 3357, in main
_run_command(command, site, global_opts, args, options)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/main.py”, line 3319, in _run_command
omdlib.backup.main_backup(object(), site, global_opts, args, command_options )
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 117 , in main_backup
returncode = main_site_backup(backup_args)
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 135 , in main_site_backup
_try_backup_site_to_tarfile(tar, BackupExclusions.from_args(args), site, arg s.verbose)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 61, in _try_backup_site_to_tarfile
_backup_site_to_tarfile(
~~~~~~~~~~~~~~~~~~~~~~~^
site.name,
^^^^^^^^^^
…<4 lines>…
verbose,
^^^^^^^^
)
^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 182 , in _backup_site_to_tarfile
_tar_add(
~~~~~~~~^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 419 , in _tar_add
_tar_add( # recursive call
~~~~~~~~^^^^^^^^^^^^^^^^^^^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 419 , in _tar_add
_tar_add( # recursive call
~~~~~~~~^^^^^^^^^^^^^^^^^^^
rrd_socket,
^^^^^^^^^^^
…<4 lines>…
verbose=verbose,
^^^^^^^^^^^^^^^^
)
^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 388 , in _tar_add
tarinfo = _get_tar_info_or_raise(tar, name, arcname)
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 475 , in _get_tar_info_or_raise
raise tarfile.TarError(f"Failed to get tarinfo for file {name!r}")
tarfile.TarError: Failed to get tarinfo for file ‘/omd/sites/cmk/.gunicorn/gunic orn.ctl’

I have a new patch which excludes all devices, fifos and sockets. In my case there are sockets which cause the backup to fail:

--- /omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py.orig  2026-09-08 16:19:49.000000000 +0200
+++ /omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py       2026-09-11 14:34:16.369296309 +0200
@@ -384,6 +384,9 @@
     directory_files = []
     try:
         with rrd_socket.suspend_rrd_update_if_needed(arcname):
+            # skip block devices, fifos and sockets
+            if os.stat(name).st_mode & 0o170000 in [0o060000, 0o010000, 0o140000]:
+                return
             # Create a TarInfo object from the file.
             tarinfo = _get_tar_info_or_raise(tar, name, arcname)
             # Exclude files.
             if not predicate(tarinfo):
                 return 

Site backup failed: Traceback (most recent call last):
File “/omd/sites/cmk/bin/omd”, line 51, in
import omdlib.main # noqa: E402
^^^^^^^^^^^^^^^^^^
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/main.py”, line 37, in
import omdlib.backup
File “/omd/versions/2.5.0p13.community/lib/python3/omdlib/backup.py”, line 388
if os.stat(name).st_mode & 0o170000 in [0o060000, 0o010000, 0o140000]:
IndentationError: expected an indented block after ‘with’ statement on line 386