From 95d89cece228a53b598a531f15f40ba7d342bd08 Mon Sep 17 00:00:00 2001 From: Tal Zussman <32444106+tzussman@users.noreply.github.com> Date: Sun, 11 Jun 2023 16:19:18 -0400 Subject: [PATCH] Create backup.sh --- backup.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 backup.sh diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..242d6ff --- /dev/null +++ b/backup.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Back up student repos from Github using a base assignment repo +# Requires that base assignment repo contains the base commit in student repos + +if [[ $# != 1 ]]; then + echo "usage: backup.sh " + exit 1 +fi + +HWS=(hw3 hw4 hw5 hw6 hw7 hw8) +MANIFEST=$1 +ORG=cs4118-hw + +for hw in ${HWS[@]}; do + grep "$hw" "$MANIFEST" > "$hw.txt" + git clone "git@github.com:$ORG/$hw.git" "$hw" + for repo in $(cat "$hw.txt"); do + repo_name=${repo##*/} + echo "$repo_name" + if [[ -d "$repo_name" ]]; then + continue + fi + git clone "$hw" "$repo_name" || continue + cd "$repo_name" || continue + git remote set-url origin "git@github.com:$repo" + git pull origin + cd .. + done + rm -f "$hw.txt" +done