slaprunner: Add a backup signature using sha256sum
[slapos.git] / software / slaprunner / template / runner-export.sh.jinja2
1 #!{{ shell_binary }}
2 LANG=en_US
3 export $LANG
4 umask 077
5 sync_element () {
6   path=$1
7   backup_path=$2
8   shift 2
9   element_list=$*
10   for element in $element_list
11   do
12     cd $path;
13     if [ -f $element ] || [ -d $element ]; then
14        {{ rsync_binary }} -av --safe-links --delete $element  $backup_path;
15     fi
16   done
17 }
18 sync_element {{ directory['srv'] }}/runner  {{ directory['backup'] }}/runner/ instance project  proxy.db
19 # We sync .* appart
20 date +%s -u > {{ directory['etc'] }}/.resilient-timestamp
21 cp -r {{ directory['etc'] }}/.??* {{ directory['backup'] }}/etc/
22 sync_element {{ directory['etc'] }}  {{ directory['backup'] }}/etc/ config.json ssh
23 if [ -d {{ directory['backup'] }}/runner/software ]; then
24   rm {{ directory['backup'] }}/runner/software/*
25 fi
26
27 cd {{ directory['backup'] }} && find -type f ! -name backup.signature -exec sha256sum {} + > backup.signature