Bugfix: - vmdk imports
- stats logs with rsync
This commit is contained in:
parent
a9aa653b02
commit
d554c478f2
@ -139,7 +139,7 @@ class backup_rsync(backup_generic):
|
||||
backup_source = '%s@%s::%s%s' % (self.remote_user, self.server_name, self.rsync_module, self.remote_dir)
|
||||
else:
|
||||
# case of rsync + ssh
|
||||
ssh_params = ['-o StrictHostKeyChecking=no','-c blowfish']
|
||||
ssh_params = ['-o StrictHostKeyChecking=no','-c %s' % self.cipher_spec]
|
||||
if self.private_key:
|
||||
ssh_params.append('-i %s' % self.private_key)
|
||||
if self.ssh_port <> 22:
|
||||
@ -168,13 +168,13 @@ class backup_rsync(backup_generic):
|
||||
|
||||
for l in log.splitlines():
|
||||
if l.startswith('Number of files:'):
|
||||
stats['total_files_count'] += int(l.split(':')[1])
|
||||
stats['total_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1]))
|
||||
if l.startswith('Number of files transferred:'):
|
||||
stats['written_files_count'] += int(l.split(':')[1])
|
||||
stats['written_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1]))
|
||||
if l.startswith('Total file size:'):
|
||||
stats['total_bytes'] += int(l.split(':')[1].split()[0])
|
||||
stats['total_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0]))
|
||||
if l.startswith('Total transferred file size:'):
|
||||
stats['written_bytes'] += int(l.split(':')[1].split()[0])
|
||||
stats['written_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0]))
|
||||
|
||||
returncode = process.returncode
|
||||
## deal with exit code 24 (file vanished)
|
||||
@ -310,7 +310,8 @@ class backup_rsync_ssh(backup_rsync):
|
||||
"""Backup a directory on remote server with rsync and ssh protocol (requires rsync software on remote host)"""
|
||||
type = 'rsync+ssh'
|
||||
required_params = backup_generic.required_params + ['remote_user','remote_dir','private_key']
|
||||
optional_params = backup_generic.optional_params + ['compression','bwlimit','ssh_port','exclude_list','protect_args','overload_args']
|
||||
optional_params = backup_generic.optional_params + ['compression','bwlimit','ssh_port','exclude_list','protect_args','overload_args', 'cipher_spec']
|
||||
cipher_spec = 'cipher_spec'
|
||||
|
||||
|
||||
register_driver(backup_rsync)
|
||||
|
@ -44,11 +44,12 @@ class backup_vmdk(backup_generic):
|
||||
type = 'esx-vmdk'
|
||||
|
||||
required_params = backup_generic.required_params + ['esxhost','password_file','server_name']
|
||||
optional_params = backup_generic.optional_params + ['esx_port', 'prefix_clone', 'create_ovafile']
|
||||
optional_params = backup_generic.optional_params + ['esx_port', 'prefix_clone', 'create_ovafile', 'halt_vm']
|
||||
|
||||
esx_port = 443
|
||||
prefix_clone = "clone-"
|
||||
create_ovafile = "no"
|
||||
halt_vm = "no"
|
||||
|
||||
def make_compatible_cookie(self,client_cookie):
|
||||
cookie_name = client_cookie.split("=", 1)[0]
|
||||
@ -234,19 +235,26 @@ class backup_vmdk(backup_generic):
|
||||
vmList = vmFolder.childEntity
|
||||
for vm in vmList:
|
||||
if vm.name == self.server_name:
|
||||
if not vm.summary.runtime.powerState == "poweredOff":
|
||||
vm_is_off = vm.summary.runtime.powerState == "poweredOff"
|
||||
if str2bool(self.halt_vm):
|
||||
vm.ShutdownGuest()
|
||||
vm_is_off = True
|
||||
|
||||
if vm_is_off:
|
||||
vmdks = self.export_vmdks(vm)
|
||||
ovf_filename = self.create_ovf(vm, vmdks)
|
||||
else:
|
||||
new_vm = self.clone_vm(vm)
|
||||
vmdks = self.export_vmdks(new_vm)
|
||||
ovf_filename = self.create_ovf(vm, vmdks)
|
||||
if str2bool(self.create_ovafile):
|
||||
ova_filename = self.create_ova(vm, vmdks, ovf_filename)
|
||||
self.wait_task(new_vm.Destroy_Task())
|
||||
else:
|
||||
vmdks = self.export_vmdks(vm)
|
||||
ovf_filename = self.create_ovf(vm, vmdks)
|
||||
if str2bool(self.create_ovafile):
|
||||
ova_filename = self.create_ova(vm, vmdks, ovf_filename)
|
||||
|
||||
self.wait_task(new_vm.Destroy_Task())
|
||||
|
||||
if str2bool(self.create_ovafile):
|
||||
ova_filename = self.create_ova(vm, vmdks, ovf_filename)
|
||||
|
||||
if str2bool(self.halt_vm):
|
||||
vm.PowerOnVM()
|
||||
|
||||
|
||||
if os.path.exists(dest_dir):
|
||||
for file in os.listdir(dest_dir):
|
||||
|
@ -91,3 +91,9 @@ db_user=sa
|
||||
db_password=xxx
|
||||
|
||||
|
||||
[debian-ovf]
|
||||
type=esx-vmdk
|
||||
server_name=debian
|
||||
esxhost=192.168.149.213
|
||||
password_file=/etc/.esx_passwd
|
||||
create_ovafile=yes
|
||||
|
1
tisbackup.py
Normal file → Executable file
1
tisbackup.py
Normal file → Executable file
@ -36,6 +36,7 @@ from libtisbackup.backup_rsync_btrfs import backup_rsync_btrfs
|
||||
from libtisbackup.backup_rsync_btrfs import backup_rsync__btrfs_ssh
|
||||
from libtisbackup.backup_pgsql import backup_pgsql
|
||||
from libtisbackup.backup_xva import backup_xva
|
||||
from libtisbackup.backup_vmdk import backup_vmdk
|
||||
#from libtisbackup.backup_switch import backup_switch
|
||||
from libtisbackup.backup_null import backup_null
|
||||
from libtisbackup.backup_xcp_metadata import backup_xcp_metadata
|
||||
|
Loading…
Reference in New Issue
Block a user