summaryrefslogtreecommitdiffstats
path: root/backup.sh
diff options
context:
space:
mode:
authorkhilman <khilman@users.noreply.github.com>2018-07-20 11:38:40 -0500
committerGitHub <noreply@github.com>2018-07-20 11:38:40 -0500
commit45f76344b4278f1ecf9956f3a81bfe11cd525c43 (patch)
tree08cfb059940190cac3eb62bcb8b5a6d01ca67396 /backup.sh
parented83f7aa1af39e75c10d5e8c4f1385c302beec12 (diff)
parent0f09e5c9b89cee21a6ee39db9daf8e17525dd493 (diff)
Merge pull request #32 from montjoie/persistantdb_pr
Persistantdb pr
Diffstat (limited to 'backup.sh')
-rwxr-xr-xbackup.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/backup.sh b/backup.sh
new file mode 100755
index 0000000..f803486
--- /dev/null
+++ b/backup.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+BACKUP_DIR="backup-$(date +%Y%m%d_%H%M)"
+
+mkdir $BACKUP_DIR
+cp boards.yaml $BACKUP_DIR
+
+DOCKERID=$(docker ps |grep master | cut -d' ' -f1)
+if [ -z "$DOCKERID" ];then
+ exit 1
+fi
+# 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 $?
+docker cp $DOCKERID:/tmp/db_lavaserver.gz $BACKUP_DIR/ || exit $?
+docker exec -ti $DOCKERID rm /tmp/db_lavaserver.gz || exit $?
+
+docker exec -ti $DOCKERID tar czf /root/joboutput.tar.gz /var/lib/lava-server/default/media/job-output/ || exit $?
+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"