Bug 15661 - Online backup fails when smb over tcp is missing
Summary: Online backup fails when smb over tcp is missing
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: 4.20.1
Hardware: All All
: P5 minor (vote)
Target Milestone: ---
Assignee: Douglas Bagnall
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-10 20:12 UTC by Thomas Karlsson
Modified: 2024-07-05 17:25 UTC (History)
1 user (show)

See Also:


Attachments
Patch to ignore sysvol backup when smb is not running (991 bytes, patch)
2024-06-13 17:48 UTC, Thomas Karlsson
no flags Details
Patch to enable a new option --no-sysvol for backup (2.15 KB, patch)
2024-07-05 17:25 UTC, Thomas Karlsson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Karlsson 2024-06-10 20:12:56 UTC
If SMB over tcp is not running (port 445), then samba-tool domain backup online --server localhost --targetdir=backup will fail with an exception.

It crashes when trying to backup the sysvol.
My suggestion is to add a try and except block on line 278 to catch the exception.

I can provide a patch file, or make a pull request. If you want.
Comment 1 Douglas Bagnall 2024-06-11 22:03:44 UTC
> I can provide a patch file, or make a pull request. If you want.

A patch is good. It would also be good to see the traceback.
Comment 2 Thomas Karlsson 2024-06-13 17:48:28 UTC
Created attachment 18339 [details]
Patch to ignore sysvol backup when smb is not running

Adding a try and except when trying to connect to smb share sysvol.
Comment 3 Thomas Karlsson 2024-06-13 17:57:41 UTC
Here is the exception.
Note that the exception comes from another version of Samba, I think 4.13.x, but it is still the same problem in the latest version.


Connecting to 192.168.10.1 at port 445
ERROR(runtime): uncaught exception - (3221226038, 'The transport-connection attempt was refused by the remote system.')
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py, line 186, in _run
    return self.run(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/samba/netcmd/domain_backup.py", line 271, in run
    smb_conn = smb_sysvol_conn(server, lp, creds)
  File "/usr/lib/python3/dist-packages/samba/netcmd/domain_backup.py", line 116, in smb_sysvol_conn
    return libsmb.Conn(server, "sysvol", lp=s3_lp, creds=creds, sign=True)
Comment 4 Stefan Metzmacher 2024-06-14 07:21:36 UTC
(In reply to Thomas Karlsson from comment #3)

In what situation does that happen? A Windows DC only providing QUIC?

A backup without the sysvol content is useless.

I think we should not silently ignore the error,
an explicit --no-sysvol options would be ok if needed.
Comment 5 Thomas Karlsson 2024-06-17 17:19:14 UTC
(In reply to Stefan Metzmacher from comment #4)

I only use Samba AD for authentication and authorisation (group handling) and not client management, so sysvol isn't used.
These options are in the smb.conf

server services = rpc, ldap, cldap, kdc, drepl, kcc, dnsupdate

The backup fails with these services.

I think the backup still is relevant without sysvol. For example the users and dns.
Comment 6 Stefan Metzmacher 2024-07-05 10:02:18 UTC
(In reply to Thomas Karlsson from comment #5)

Ok, then an explicit --no-sysvol would work...
Comment 7 Thomas Karlsson 2024-07-05 17:25:12 UTC
Created attachment 18364 [details]
Patch to enable a new option --no-sysvol for backup

Made a patch to enable the new option --no-sysvol