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: 2025-03-29 08:26 UTC (History)
2 users (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
Patch to enable no_sysvol option (2.09 KB, patch)
2025-03-03 20:39 UTC, Thomas Karlsson
no flags Details
git format-patch patch (2.82 KB, patch)
2025-03-19 01:51 UTC, Douglas Bagnall
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
Comment 8 Douglas Bagnall 2025-02-20 01:54:10 UTC
Thomas, are you able to provide the --no-sysvol patch using a git commit and `git format-patch`?

And also read https://www.samba.org/samba/devel/copyright-policy.html and send in the paperwork mentioned there?

You can use something like `git commit -sm "samba-tool domain backup: add --no-sysvol option"`.


Also, I am uncertain about this part of it:

-            # remove the default sysvol files created by the clone (we want to
-            # make sure we restore the sysvol.tar.gz files instead)
-            shutil.rmtree(paths.sysvol)
[...]
+                # remove the default sysvol files created by the clone (we want to
+                # make sure we restore the sysvol.tar.gz files instead)
+                shutil.rmtree(paths.sysvol)

if we are using --no-sysvol, do we want the sysvol files created by the clone, or do we really want no sysvol at all?
Comment 9 Thomas Karlsson 2025-03-02 16:29:54 UTC
I am new to this. Do I attach the "git format-patch" output here in a comment?
Comment 10 Douglas Bagnall 2025-03-02 22:48:48 UTC
(In reply to Thomas Karlsson from comment #9)

Adding an attachment is best.
Comment 11 Thomas Karlsson 2025-03-03 20:39:46 UTC
Created attachment 18592 [details]
Patch to enable no_sysvol option

Patch to enable a new option to exclude sysvol in backup.
Comment 12 Douglas Bagnall 2025-03-19 01:51:13 UTC
Created attachment 18614 [details]
git format-patch  patch

This is the patch in 'git format-patch' form.

Thomas, I used your name for authorship and signed-off-by, so please check I didn't do anything wrong.
Comment 13 Thomas Karlsson 2025-03-19 18:17:15 UTC
I think it looks great!
Comment 14 Samba QA Contact 2025-03-26 01:52:38 UTC
This bug was referenced in samba master:

1d39baf1e7c128d89bfa204ef83d4c61b30a58d9
Comment 15 Samba QA Contact 2025-03-29 08:26:22 UTC
This bug was referenced in samba master:

a65a9e2e34cf02cd10ec9028782f7a43dc6cfebb