diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 176bab0..6664a0d 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -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 diff --git a/backup.sh b/backup.sh index 2f5f748..685baa1 100755 --- a/backup.sh +++ b/backup.sh @@ -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 diff --git a/boards-ci-testbackup.yaml b/boards-ci-testbackup.yaml new file mode 100644 index 0000000..6ab6cc8 --- /dev/null +++ b/boards-ci-testbackup.yaml @@ -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