summaryrefslogtreecommitdiffstats
path: root/lava-master
diff options
context:
space:
mode:
Diffstat (limited to 'lava-master')
-rwxr-xr-xlava-master/entrypoint.d/01_setup.sh47
1 files changed, 26 insertions, 21 deletions
diff --git a/lava-master/entrypoint.d/01_setup.sh b/lava-master/entrypoint.d/01_setup.sh
index 95b180b..e3619f7 100755
--- a/lava-master/entrypoint.d/01_setup.sh
+++ b/lava-master/entrypoint.d/01_setup.sh
@@ -16,32 +16,37 @@ else
sed -i "s,PASSWORD:.*,PASSWORD: '$(cat /root/pg_lava_password)'," /etc/lava-server/settings.d/00-database.yaml || exit $?
fi
-if [ -e /root/backup/db_lavaserver.gz ];then
- gunzip /root/backup/db_lavaserver.gz || exit $?
-fi
-
-if [ -e /root/backup/db_lavaserver ];then
- echo "Restore database from backup"
- sudo -u postgres psql < /root/backup/db_lavaserver || exit $?
- yes yes | lava-server manage migrate || exit $?
- echo "Restore jobs output from backup"
- rm -r /var/lib/lava-server/default/media/job-output/*
+# verify that the backup was not already applied in case of persistent_db
+if [ ! -e "/var/lib/postgresql/lava-docker.backup_done" ];then
+ if [ -e /root/backup/db_lavaserver.gz ];then
+ gunzip /root/backup/db_lavaserver.gz || exit $?
+ fi
- # allow using different folder for tar operations (/tmp by default)
- TMPDIR=${TMPDIR:-/tmp}
+ if [ -e /root/backup/db_lavaserver ];then
+ echo "Restore database from backup"
+ sudo -u postgres psql < /root/backup/db_lavaserver || exit $?
+ yes yes | lava-server manage migrate || exit $?
+ echo "Restore jobs output from backup"
+ rm -r /var/lib/lava-server/default/media/job-output/*
- tar xzf /root/backup/joboutput.tar.gz || exit $?
-fi
- lava-server manage makemigrations
- yes yes | lava-server manage migrate || exit $?
+ # allow using different folder for tar operations (/tmp by default)
+ TMPDIR=${TMPDIR:-/tmp}
-if [ -e /root/backup/devices.tar.gz ];then
- echo "INFO: Restoring devices files"
- tar xzf /root/backup/devices.tar.gz
- chown -R lavaserver:lavaserver /etc/lava-server/dispatcher-config/devices
+ tar xzf /root/backup/joboutput.tar.gz || exit $?
+ chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/
+ touch /var/lib/postgresql/lava-docker.backup_done
+ fi
+ if [ -e /root/backup/devices.tar.gz ];then
+ echo "INFO: Restoring devices files"
+ tar xzf /root/backup/devices.tar.gz
+ chown -R lavaserver:lavaserver /etc/lava-server/dispatcher-config/devices
+ fi
+else
+ echo "DEBUG: backup already applied"
fi
-chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/
+lava-server manage makemigrations
+yes yes | lava-server manage migrate || exit $?
# default site is set as example.com
if [ -e /root/lava_http_fqdn ];then