Commit 2e3922a9 authored by Łukasz Nowak's avatar Łukasz Nowak

software/kvm: Recover from empty backup

parent b209f5ca
......@@ -43,7 +43,7 @@ md5sum = a02f0694dcb944c18d99f7f79afa2384
[template-kvm-export-script]
filename = template/kvm-export.sh.jinja2
md5sum = 3540b42e0869b409846a1601b6ea4dcc
md5sum = ba1e0359178925788792a1c6cc29ba59
[template-nginx]
filename = template/nginx_conf.in
......
......@@ -28,6 +28,9 @@ if [ $RESULT -ne 0 ] ; then
find $BACKUP_DIR/{{ disk['device'] }} -name '*.qcow2' -delete
$qmpbackup --level full || exit $?
echo "Post take-over cleanup"
elif egrep -q 'No full backup found for device.*{{ disk['device']}}.*in.*{{ disk['device']}}.*: Execute full backup first.' $log ; then
$qmpbackup --level full || exit $?
echo "Recovered from empty backup"
else
exit $RESULT
fi
......
......@@ -966,6 +966,10 @@ class TestInstanceResilientBackupExporter(
'Recovered from partial backup by removing partial',
status_text
)
self.assertNotIn(
'Recovered from empty backup',
status_text
)
# cover .partial file in the backup directory with fallback to full
current_backup = glob.glob(self.getBackupPartitionPath('FULL-*'))[0]
with open(current_backup + '.partial', 'w') as fh:
......@@ -984,6 +988,25 @@ class TestInstanceResilientBackupExporter(
self.assertTrue(os.path.exists(os.path.join(
self.getPartitionPath(
'kvm-export', 'etc', 'plugin', 'check-backup-directory.py'))))
# cover empty backup recovery
current_backup_list = glob.glob(self.getBackupPartitionPath('*.qcow2'))
self.assertEqual(
1,
len(current_backup_list)
)
for file in current_backup_list:
os.unlink(file)
status_text = self.call_exporter()
self.assertEqual(
len(glob.glob(self.getBackupPartitionPath('FULL-*.qcow2'))),
1)
self.assertEqual(
len(glob.glob(self.getBackupPartitionPath('INC-*.qcow2'))),
0)
self.assertIn(
'Recovered from empty backup',
status_text
)
@skipUnlessKvm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment