From 5787bbd116b65d4be872dcca76d0049899a53a2d Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Tue, 11 Dec 2018 10:02:01 +0100 Subject: lava-master: use /root/backup/ for storing backups For storing backups to be restored, it is better to use /root/backup/ instead of / --- lava-master/scripts/setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lava-master/scripts') diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh index 34cd0a1..9864ad2 100755 --- a/lava-master/scripts/setup.sh +++ b/lava-master/scripts/setup.sh @@ -7,18 +7,19 @@ 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 $? +if [ -e /root/backup/db_lavaserver.gz ];then + gunzip /root/backup/db_lavaserver.gz || exit $? fi -if [ -e /db_lavaserver ];then +if [ -e /root/backup/db_lavaserver ];then echo "Restore database from backup" - sudo -u postgres psql < /db_lavaserver || exit $? + sudo -u postgres psql < /root/backup/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 $? + tar xzf /root/backup/joboutput.tar.gz || exit $? fi + chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/ # default site is set as example.com -- cgit 1.2.3-korg From 290612eef95ffca9b6c9a28224be6f51c55bddcd Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Tue, 11 Dec 2018 10:02:54 +0100 Subject: backup: backup also devices files The current way to do backup assume that slave will be restarted after each master maintainance. If master is restarted from backup without slaves restarting bring to devices files missing. By backuping devices, a master can be restored from backup without needing slaves worker to be restarted. --- backup.sh | 4 ++++ lava-master/scripts/setup.sh | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'lava-master/scripts') diff --git a/backup.sh b/backup.sh index 3477367..f4cf1de 100755 --- a/backup.sh +++ b/backup.sh @@ -9,6 +9,10 @@ DOCKERID=$(docker ps |grep master | cut -d' ' -f1) if [ -z "$DOCKERID" ];then exit 1 fi + +docker exec -ti $DOCKERID tar czf /root/devices.tar.gz /etc/lava-server/dispatcher-config/devices/ || exit $? +docker cp $DOCKERID:/root/devices.tar.gz $BACKUP_DIR/ || exit $? + # for an unknown reason pg_dump > file doesnt work docker exec -ti $DOCKERID sudo -u postgres pg_dump --create --clean lavaserver --file /tmp/db_lavaserver || exit $? docker exec -ti $DOCKERID gzip /tmp/db_lavaserver || exit $? diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh index 9864ad2..6153c9d 100755 --- a/lava-master/scripts/setup.sh +++ b/lava-master/scripts/setup.sh @@ -20,6 +20,12 @@ if [ -e /root/backup/db_lavaserver ];then tar xzf /root/backup/joboutput.tar.gz || exit $? 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 + chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/ # default site is set as example.com -- cgit 1.2.3-korg