diff options
-rwxr-xr-x | backup.sh | 5 | ||||
-rw-r--r-- | lava-master/Dockerfile | 2 | ||||
-rwxr-xr-x | lava-master/scripts/setup.sh | 17 |
3 files changed, 18 insertions, 6 deletions
@@ -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 $? @@ -20,4 +24,5 @@ docker cp $DOCKERID:/root/joboutput.tar.gz $BACKUP_DIR/ || exit $? docker exec -ti $DOCKERID rm /root/joboutput.tar.gz || exit $? echo "Backup done in $BACKUP_DIR" +rm -f backup-latest ln -sf $BACKUP_DIR backup-latest diff --git a/lava-master/Dockerfile b/lava-master/Dockerfile index fb28bc9..9de656f 100644 --- a/lava-master/Dockerfile +++ b/lava-master/Dockerfile @@ -1,6 +1,6 @@ FROM baylibre/lava-master-base:latest -COPY backup / +COPY backup /root/backup/ COPY configs/tftpd-hpa /etc/default/tftpd-hpa diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh index 34cd0a1..6153c9d 100755 --- a/lava-master/scripts/setup.sh +++ b/lava-master/scripts/setup.sh @@ -7,18 +7,25 @@ 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 + +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 |