mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
netcmd: domain backup offline command
Unlike the existing 'domain backup online' command, this command allows an admin to back up a local samba installation using the filesystem and the tdbbackup tool instead of using remote protocols. It replaces samba_backup as that tool does not handle sam.ldb and secrets.ldb correctly. Those two databases need to have transactions started on them before their downstream ldb and tdb files are backed up. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
committed by
Gary Lockyer
parent
4f532cc177
commit
f17d20123a
@ -22,7 +22,7 @@ import samba
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
def tdb_copy(file1, file2):
|
||||
def tdb_copy(file1, file2, readonly=False):
|
||||
"""Copy tdb file using tdbbackup utility and rename it
|
||||
"""
|
||||
# Find the location of tdbbackup tool
|
||||
@ -33,9 +33,9 @@ def tdb_copy(file1, file2):
|
||||
break
|
||||
|
||||
tdbbackup_cmd = [toolpath, "-s", ".copy.tdb", file1]
|
||||
status = subprocess.call(tdbbackup_cmd, close_fds=True, shell=False)
|
||||
if readonly:
|
||||
tdbbackup_cmd.append("-r")
|
||||
|
||||
if status == 0:
|
||||
os.rename("%s.copy.tdb" % file1, file2)
|
||||
else:
|
||||
raise Exception("Error copying %s" % file1)
|
||||
status = subprocess.check_call(tdbbackup_cmd, close_fds=True, shell=False)
|
||||
|
||||
os.rename("%s.copy.tdb" % file1, file2)
|
||||
|
Reference in New Issue
Block a user