This commit is contained in:
parent
da50051a3f
commit
b805f8387e
@ -164,7 +164,7 @@ class backup_mysql(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -144,7 +144,7 @@ class backup_oracle(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -142,7 +142,7 @@ class backup_pgsql(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -139,8 +139,8 @@ class backup_rsync(backup_generic):
|
|||||||
if not self.rsync_module and not self.private_key:
|
if not self.rsync_module and not self.private_key:
|
||||||
raise Exception("If you don" "t use SSH, you must specify a rsync module")
|
raise Exception("If you don" "t use SSH, you must specify a rsync module")
|
||||||
|
|
||||||
# rsync_re = re.compile('(?P<server>[^:]*)::(?P<export>[^/]*)/(?P<path>.*)')
|
# rsync_re = re.compile(r'(?P<server>[^:]*)::(?P<export>[^/]*)/(?P<path>.*)')
|
||||||
# ssh_re = re.compile('((?P<user>.*)@)?(?P<server>[^:]*):(?P<path>/.*)')
|
# ssh_re = re.compile(r'((?P<user>.*)@)?(?P<server>[^:]*):(?P<path>/.*)')
|
||||||
|
|
||||||
# Add ssh connection params
|
# Add ssh connection params
|
||||||
if self.rsync_module:
|
if self.rsync_module:
|
||||||
@ -182,8 +182,8 @@ class backup_rsync(backup_generic):
|
|||||||
|
|
||||||
log = monitor_stdout(process, ondata, self)
|
log = monitor_stdout(process, ondata, self)
|
||||||
|
|
||||||
reg_total_files = re.compile("Number of files: (?P<file>\d+)")
|
reg_total_files = re.compile(r"Number of files: (?P<file>\d+)")
|
||||||
reg_transferred_files = re.compile("Number of .*files transferred: (?P<file>\d+)")
|
reg_transferred_files = re.compile(r"Number of .*files transferred: (?P<file>\d+)")
|
||||||
for l in log.splitlines():
|
for l in log.splitlines():
|
||||||
line = l.replace(",", "")
|
line = l.replace(",", "")
|
||||||
m = reg_total_files.match(line)
|
m = reg_total_files.match(line)
|
||||||
@ -242,8 +242,8 @@ class backup_rsync(backup_generic):
|
|||||||
filelist.sort()
|
filelist.sort()
|
||||||
filelist.reverse()
|
filelist.reverse()
|
||||||
# full = ''
|
# full = ''
|
||||||
r_full = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
r_full = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
r_partial = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}.rsync$")
|
r_partial = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}.rsync$")
|
||||||
# we take all latest partials younger than the latest full and the latest full
|
# we take all latest partials younger than the latest full and the latest full
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if r_partial.match(item) and item < current:
|
if r_partial.match(item) and item < current:
|
||||||
@ -264,7 +264,7 @@ class backup_rsync(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -146,8 +146,8 @@ class backup_rsync_btrfs(backup_generic):
|
|||||||
if not self.rsync_module and not self.private_key:
|
if not self.rsync_module and not self.private_key:
|
||||||
raise Exception("If you don" "t use SSH, you must specify a rsync module")
|
raise Exception("If you don" "t use SSH, you must specify a rsync module")
|
||||||
|
|
||||||
# rsync_re = re.compile('(?P<server>[^:]*)::(?P<export>[^/]*)/(?P<path>.*)')
|
# rsync_re = re.compile(r'(?P<server>[^:]*)::(?P<export>[^/]*)/(?P<path>.*)')
|
||||||
# ssh_re = re.compile('((?P<user>.*)@)?(?P<server>[^:]*):(?P<path>/.*)')
|
# ssh_re = re.compile(r'((?P<user>.*)@)?(?P<server>[^:]*):(?P<path>/.*)')
|
||||||
|
|
||||||
# Add ssh connection params
|
# Add ssh connection params
|
||||||
if self.rsync_module:
|
if self.rsync_module:
|
||||||
@ -187,8 +187,8 @@ class backup_rsync_btrfs(backup_generic):
|
|||||||
|
|
||||||
log = monitor_stdout(process, ondata, self)
|
log = monitor_stdout(process, ondata, self)
|
||||||
|
|
||||||
reg_total_files = re.compile("Number of files: (?P<file>\d+)")
|
reg_total_files = re.compile(r"Number of files: (?P<file>\d+)")
|
||||||
reg_transferred_files = re.compile("Number of .*files transferred: (?P<file>\d+)")
|
reg_transferred_files = re.compile(r"Number of .*files transferred: (?P<file>\d+)")
|
||||||
for l in log.splitlines():
|
for l in log.splitlines():
|
||||||
line = l.replace(",", "")
|
line = l.replace(",", "")
|
||||||
m = reg_total_files.match(line)
|
m = reg_total_files.match(line)
|
||||||
@ -260,8 +260,8 @@ class backup_rsync_btrfs(backup_generic):
|
|||||||
filelist.sort()
|
filelist.sort()
|
||||||
filelist.reverse()
|
filelist.reverse()
|
||||||
# full = ''
|
# full = ''
|
||||||
r_full = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
r_full = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
r_partial = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}.rsync$")
|
r_partial = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}.rsync$")
|
||||||
# we take all latest partials younger than the latest full and the latest full
|
# we take all latest partials younger than the latest full and the latest full
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if r_partial.match(item) and item < current:
|
if r_partial.match(item) and item < current:
|
||||||
@ -281,7 +281,7 @@ class backup_rsync_btrfs(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -143,7 +143,7 @@ class backup_samba4(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
p = re.compile(r"^\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}$")
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if p.match(item):
|
if p.match(item):
|
||||||
dir_name = os.path.join(self.backup_dir, item)
|
dir_name = os.path.join(self.backup_dir, item)
|
||||||
|
@ -147,7 +147,7 @@ class backup_sqlserver(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^%s-(?P<date>\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}).bak.gz$" % self.db_name)
|
p = re.compile(r"^%s-(?P<date>\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}).bak.gz$" % self.db_name)
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
sr = p.match(item)
|
sr = p.match(item)
|
||||||
if sr:
|
if sr:
|
||||||
|
@ -206,7 +206,7 @@ class backup_switch(backup_generic):
|
|||||||
child.expect("#--")
|
child.expect("#--")
|
||||||
child.expect("#")
|
child.expect("#")
|
||||||
child.close()
|
child.close()
|
||||||
myre = re.compile("#--+")
|
myre = re.compile(r"#--+")
|
||||||
config = myre.split(open(filename).read())[2]
|
config = myre.split(open(filename).read())[2]
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
f.write(config)
|
f.write(config)
|
||||||
|
@ -73,7 +73,7 @@ class backup_xcp_metadata(backup_generic):
|
|||||||
|
|
||||||
filelist = os.listdir(self.backup_dir)
|
filelist = os.listdir(self.backup_dir)
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
p = re.compile("^%s-(?P<date>\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}).dump.gz$" % self.server_name)
|
p = re.compile(r"^%s-(?P<date>\d{8,8}-\d{2,2}h\d{2,2}m\d{2,2}).dump.gz$" % self.server_name)
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
sr = p.match(item)
|
sr = p.match(item)
|
||||||
if sr:
|
if sr:
|
||||||
|
@ -586,7 +586,7 @@ class backup_generic(ABC):
|
|||||||
ssh_port = 22
|
ssh_port = 22
|
||||||
|
|
||||||
def __init__(self, backup_name, backup_dir, dbstat=None, dry_run=False):
|
def __init__(self, backup_name, backup_dir, dbstat=None, dry_run=False):
|
||||||
if not re.match("^[A-Za-z0-9_\-\.]*$", backup_name):
|
if not re.match(r"^[A-Za-z0-9_\-\.]*$", backup_name):
|
||||||
raise Exception("The backup name %s should contain only alphanumerical characters" % backup_name)
|
raise Exception("The backup name %s should contain only alphanumerical characters" % backup_name)
|
||||||
self.backup_name = backup_name
|
self.backup_name = backup_name
|
||||||
self.backup_dir = backup_dir
|
self.backup_dir = backup_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user