Skip to content

Commit

Permalink
Let backup handle docker name different than master
Browse files Browse the repository at this point in the history
Signed-off-by: Corentin LABBE <[email protected]>
  • Loading branch information
montjoie committed Jan 8, 2025
1 parent 106a7c2 commit 9414b74
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,23 @@ jobs:
run: cd output/local && docker compose up -d
- name: Wait for LAVA 2023.10 to be started
run: sh .github/workflows/wait-for-docker.sh
test-backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: test valid and invalid usage of backup.sh
run: |
./backup.sh -n && exit 1
./backup.sh -h || exit 1
./backup.sh --help || exit 1
- run: ./lavalab-gen.py boards-ci2.yaml
- name: Build lava-docker
run: cd output/local && docker compose build
- name: Wait for LAVA to be started
run: sh .github/workflows/wait-for-docker.sh
- name: Run backup
run: ./backup.sh -n central
- name: Check backup
run: |
pwd
ls -l backup-latest
31 changes: 30 additions & 1 deletion backup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
#!/bin/sh

DOCKERNAME=master
BACKUP_DIR="backup-$(date +%Y%m%d_%H%M)"
# use /tmp by default on host (this is used by tar)
TMPDIR=${TMPDIR:-/tmp}
export TMPDIR

usage() {
echo "$0 [-h|--help] [-n dockername]"
}

while [ $# -ge 1 ]
do
case $1 in
-h)
usage
exit 0
;;
--help)
usage
exit 0
;;
-n)
shift
DOCKERNAME=$1
shift
;;
*)
usage
exit 1
;;
esac
done

mkdir -p $TMPDIR

mkdir $BACKUP_DIR
cp boards.yaml $BACKUP_DIR

DOCKERID=$(docker ps |grep master | cut -d' ' -f1)
DOCKERID=$(docker ps |grep "$DOCKERNAME" | cut -d' ' -f1)
if [ -z "$DOCKERID" ];then
echo "ERROR: unable to find docker named $DOCKERNAME"
exit 1
fi

Expand Down
28 changes: 28 additions & 0 deletions boards-ci-testbackup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
masters:
- name: central
host: local
users:
- name: admin
token: tokenforci
password: passwordforci
superuser: true
staff: true
tokens:
- username: admin
token: dfjdfkfkdjfkdsjfslforci
description: no description

slaves:
- name: lab-ci-0
host: local
remote_master: central
remote_user: admin
use_overlay_server: false
use_tftp: false
raw_devices:
- '/dev/bus/usb'

boards:
- name: qemu-01
type: qemu

0 comments on commit 9414b74

Please sign in to comment.