summaryrefslogtreecommitdiffstats
path: root/lava-master/scripts
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-07-02 15:43:25 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-07-20 11:41:58 +0200
commitd49b99094855c8bcb91fd5ab57b20249ff7ff955 (patch)
tree2c2b60a91762dc0d2f5325119fba9eb8e87d29eb /lava-master/scripts
parent70bffaef36b2afe7c732d6f20afca008c5ef1445 (diff)
Permit to backup/restore lavaserver database
This patch add an easy way to backup postgresql database and needed data stored in filesystem. In the mean time, a way to restore backup during start is added
Diffstat (limited to 'lava-master/scripts')
-rwxr-xr-xlava-master/scripts/setup.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh
index c00cb02..ad10238 100755
--- a/lava-master/scripts/setup.sh
+++ b/lava-master/scripts/setup.sh
@@ -7,6 +7,20 @@ fi
sudo -u postgres psql -c "ALTER USER lavaserver WITH PASSWORD '$(cat /root/pg_lava_password)';" || exit $?
sed -i "s,^LAVA_DB_PASSWORD=.*,LAVA_DB_PASSWORD='$(cat /root/pg_lava_password)'," /etc/lava-server/instance.conf || exit $?
+if [ -e /db_lavaserver.gz ];then
+ gunzip /db_lavaserver.gz || exit $?
+fi
+
+if [ -e /db_lavaserver ];then
+ echo "Restore database from backup"
+ sudo -u postgres psql < /db_lavaserver || exit $?
+ lava-server manage migrate || exit $?
+ echo "Restore jobs output from backup"
+ rm -r /var/lib/lava-server/default/media/job-output/*
+ tar xzf /joboutput.tar.gz || exit $?
+fi
+chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/
+
if [ -e /root/lava-users ];then
for ut in $(ls /root/lava-users)
do