Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos
Commits
2e3922a9
Commit
2e3922a9
authored
Jan 20, 2025
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/kvm: Recover from empty backup
parent
b209f5ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
software/kvm/buildout.hash.cfg
software/kvm/buildout.hash.cfg
+1
-1
software/kvm/template/kvm-export.sh.jinja2
software/kvm/template/kvm-export.sh.jinja2
+3
-0
software/kvm/test/test.py
software/kvm/test/test.py
+23
-0
No files found.
software/kvm/buildout.hash.cfg
View file @
2e3922a9
...
...
@@ -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
...
...
software/kvm/template/kvm-export.sh.jinja2
View file @
2e3922a9
...
...
@@ -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
...
...
software/kvm/test/test.py
View file @
2e3922a9
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment