Commit 10e156c9 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Marco Mariani

slaprunner: Add a backup signature using sha256sum

parent b16f2ae1
...@@ -146,21 +146,29 @@ class Recipe(GenericSlapRecipe, Notify, Callback): ...@@ -146,21 +146,29 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
# Here, two possiblities: # Here, two possiblities:
# * The first backup failed. It is safe to remove it since there is nothing valuable there. # * The first backup failed. It is safe to remove it since there is nothing valuable there.
# * The backup has been complete, but is now in a really weird state. Not safe to remove it. # * The backup has been complete, but is now in a really weird state. Not safe to remove it.
echo "Impossible to check backup: we move it to a safe place." # XXX We may need to publish the failure and ask the the equeue, re-run this script again,
# XXX: bang # instead do a push to the clone.
mv %(local_directory)s %(local_directory)s.$(date +%%s)
fi fi
else else
# Everything's okay, cleaning up... # Everything's okay, cleaning up...
$RDIFF_BACKUP --remove-older-than %(remove_backup_older_than)s --force %(local_directory)s $RDIFF_BACKUP --remove-older-than %(remove_backup_older_than)s --force %(local_directory)s
fi fi
if [ -e /srv/slapgrid/slappart17/srv/backup/pbs/COMP-1867-slappart6-runner-2/backup.signature ]; them
cd %(local_directory)s
find -type f ! -name backup.signature ! -wholename "./rdiff-backup-data/*" -print0 | xargs -0 sha256sum | sort > ../proof.signature
diff -ruw backup.signature ../proof.signature > ../backup.diff
# XXX If there is a difference on the backup, we should publish the
# failure and ask the equeue, re-run this script again,
# instead do a push it to the clone.
fi
""") """)
rdiff_wrapper_content = rdiff_wrapper_template % { rdiff_wrapper_content = rdiff_wrapper_template % {
'comment': ''.join(('# %s\n' % comment_line) for comment_line in comments), 'comment': ''.join(('# %s\n' % comment_line) for comment_line in comments),
'rdiffbackup_binary': self.options['rdiffbackup-binary'], 'rdiffbackup_binary': self.options['rdiffbackup-binary'],
'local_directory': local_directory, 'local_directory': local_directory,
'rdiffbackup_parameter': ' \\\n '.join(rdiffbackup_parameter_list), 'rdiffbackup_parameter': ' \\\n '.join(rdiffbackup_parameter_list),
# XXX: only 10 increments is not enough by default. # XXX: only 3 increments is not enough by default.
'remove_backup_older_than': entry.get('remove-backup-older-than', '3B') 'remove_backup_older_than': entry.get('remove-backup-older-than', '3B')
} }
rdiff_wrapper = self.createFile( rdiff_wrapper = self.createFile(
......
...@@ -68,7 +68,7 @@ mode = 0644 ...@@ -68,7 +68,7 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/runner-export.sh.jinja2 url = ${:_profile_base_location_}/template/runner-export.sh.jinja2
download-only = true download-only = true
md5sum = 827aca46c22017aa9ecfd8fedcad1fd0 md5sum = 86e42a6d37fde9b3b5ad1036ae25aa5c
filename = runner-export.sh.jinja2 filename = runner-export.sh.jinja2
mode = 0644 mode = 0644
......
...@@ -24,4 +24,4 @@ if [ -d {{ directory['backup'] }}/runner/software ]; then ...@@ -24,4 +24,4 @@ if [ -d {{ directory['backup'] }}/runner/software ]; then
rm {{ directory['backup'] }}/runner/software/* rm {{ directory['backup'] }}/runner/software/*
fi fi
cd {{ directory['backup'] }} && find -type f ! -name backup.signature -exec sha256sum {} + > backup.signature cd {{ directory['backup'] }} && find -type f ! -name backup.signature -print0 | xargs -0 sha256sum | sort > backup.signature
...@@ -13,6 +13,16 @@ restore_element () { ...@@ -13,6 +13,16 @@ restore_element () {
fi fi
done done
} }
write_backup_proof () {
cd {{ directory['backup'] }}
find -type f ! -name backup.signature ! -wholename "./rdiff-backup-data/*" -print0 | xargs -0 sha256sum | sort > {{ directory['srv'] }}/proof.signature
diff -ruw {{ directory['backup'] }} {{ directory['srv'] }}/proof.signature > {{ directory['srv'] }}/backup.diff
}
# For now we just make the diff before
write_backup_proof
restore_element {{ directory['backup'] }}/runner/ {{ directory['srv'] }}/runner instance project proxy.db restore_element {{ directory['backup'] }}/runner/ {{ directory['srv'] }}/runner instance project proxy.db
restore_element {{ directory['backup'] }}/etc/ {{ directory['etc'] }} config.json ssh restore_element {{ directory['backup'] }}/etc/ {{ directory['etc'] }} config.json ssh
cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }}; cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }};
......
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