-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfull.py
27 lines (20 loc) · 799 Bytes
/
full.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from backup import Backup, QMP_SHELL_PATH
from datetime import datetime
import time
class Full(Backup):
""" Make full backup of a virtual machine """
def __init__(self, vm_name):
super().__init__(vm_name)
self.full_backup_name = 'full-%s.img' % datetime.now().strftime('%Y%m%d%H%M%S')
def run(self):
super().validate()
cmd_full = 'printf "drive-backup device=disk target=%s/%s sync=full format=qcow2" | sudo %s %s' % (
self.current_backup_path,
self.full_backup_name,
QMP_SHELL_PATH,
self.socket_path
)
self.run_command(cmd_full)
# Every 3 seconds check if the backup is running and update the progress bar
while self.check_state() is False:
time.sleep(3)