1 # Unix SMB/CIFS implementation.
4 # Copyright (C) Kai Blin <kai@samba.org> 2011
5 # Copyright (C) Amitay Isaacs <amitay@gmail.com> 2011
6 # Copyright (C) Andrew Bartlett <abartlet@samba.org> 2013
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 def tdb_copy(file1
, file2
):
26 """Copy tdb file using tdbbackup utility and rename it
28 # Find the location of tdbbackup tool
29 dirs
= ["bin", samba
.param
.bin_dir()] + os
.getenv('PATH').split(os
.pathsep
)
31 toolpath
= os
.path
.join(d
, "tdbbackup")
32 if os
.path
.exists(toolpath
):
35 tdbbackup_cmd
= [toolpath
, "-s", ".copy.tdb", file1
]
36 status
= subprocess
.call(tdbbackup_cmd
, close_fds
=True, shell
=False)
39 os
.rename("%s.copy.tdb" % file1
, file2
)
41 raise Exception("Error copying %s" % file1
)