core: store date of last backup for each VM
This commit is contained in:
parent
6b59131dc9
commit
09652cb0f8
@ -126,6 +126,8 @@ class QubesVm(object):
|
||||
"backup_content" : { 'default': False },
|
||||
"backup_size" : { 'default': 0, "eval": "int(value)" },
|
||||
"backup_path" : { 'default': "" },
|
||||
"backup_timestamp": { 'eval': 'datetime.datetime.fromtimestamp('
|
||||
'int(value)) if value else None' },
|
||||
##### Internal attributes - will be overriden in __init__ regardless of args
|
||||
"config_file_template": { "eval": 'system_path["config_template_pv"]' },
|
||||
"icon_path": { "eval": 'os.path.join(self.dir_path, "icon.png") if self.dir_path is not None else None' },
|
||||
@ -155,6 +157,10 @@ class QubesVm(object):
|
||||
attrs['mac']['save'] = 'str(self._mac)'
|
||||
attrs['mac']['save_skip'] = 'self._mac is None'
|
||||
|
||||
attrs['backup_timestamp']['save'] = 'self.backup_timestamp.strftime("%s")'
|
||||
attrs['backup_timestamp']['save_skip'] = 'self.backup_timestamp is ' \
|
||||
'None'
|
||||
|
||||
attrs['netvm']['save'] = 'str(self.netvm.qid) if self.netvm is not None else "none"'
|
||||
attrs['netvm']['save_attr'] = "netvm_qid"
|
||||
attrs['template']['save'] = 'str(self.template.qid) if self.template else "none"'
|
||||
|
@ -35,6 +35,7 @@ import tempfile
|
||||
import time
|
||||
import grp,pwd
|
||||
import errno
|
||||
import datetime
|
||||
from multiprocessing import Queue,Process
|
||||
|
||||
BACKUP_DEBUG = False
|
||||
@ -660,6 +661,17 @@ def backup_do(base_backup_dir, files_to_backup, passphrase,
|
||||
print "Sparse1 proc return code:", tar_sparse.poll()
|
||||
vmproc.stdin.close()
|
||||
|
||||
# Save date of last backup
|
||||
qvm_collection = QubesVmCollection()
|
||||
qvm_collection.lock_db_for_writing()
|
||||
qvm_collection.load()
|
||||
|
||||
for vm in qvm_collection.values():
|
||||
if vm.backup_content:
|
||||
vm.backup_timestamp = datetime.datetime.now()
|
||||
|
||||
qvm_collection.save()
|
||||
qvm_collection.unlock_db()
|
||||
|
||||
'''
|
||||
' Wait for backup chunk to finish
|
||||
|
Loading…
Reference in New Issue
Block a user