mirror of
https://github.com/bairwell/github2synology.git
synced 2026-01-14 03:01:38 +00:00
Quick cleanup
This commit is contained in:
BIN
.github2synology.sh.un~
Normal file
BIN
.github2synology.sh.un~
Normal file
Binary file not shown.
@ -8,13 +8,11 @@ OAUTH_TOKEN="[PUT YOUR TOKEN HERE BETWEEN THE QUOTES]"
|
||||
# where should the files be saved
|
||||
BACKUP_PATH="/volume1/serverBackups/github/backup"
|
||||
|
||||
|
||||
# you shouldn't need to change anything below here - unless you have over 100 repos: in which case, see the bottom.
|
||||
COUNTER=100
|
||||
TOTALCOUNTER=0
|
||||
PAGE=1
|
||||
GIT="c//volume1/@appstore/git/bin/git"
|
||||
|
||||
fetch_fromUrl() {
|
||||
COUNTER=0
|
||||
API_URL="https://api.github.com/user/repos?type=all&per_page=100&page=${PAGE}"
|
||||
@ -31,8 +29,6 @@ fetch_fromUrl() {
|
||||
GITURL="${ORIGINALGITURL/git:\/\/github.com\//git@github.com:}"
|
||||
mkdir "${BACKUP_PATH}/${REPONAME}" -p
|
||||
REPOPATH="${BACKUP_PATH}/${REPONAME}/code"
|
||||
|
||||
|
||||
if [ -d "$REPOPATH" ]; then
|
||||
echo "PULLING Repo URL: ${REPONAME} from url ${GITURL} to ${REPOPATH}"
|
||||
cd ${REPOPATH}
|
||||
@ -58,7 +54,6 @@ fetch_fromUrl() {
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
until [ $COUNTER -lt 100 ]; do
|
||||
fetch_fromUrl
|
||||
|
||||
61
github2synology.sh~
Normal file
61
github2synology.sh~
Normal file
@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# A script to backup Github repositories to a Synology.
|
||||
# By Richard Bairwell. http://www.bairwell.com
|
||||
# MIT Licenced. https://github.com/bairwell/github2synology
|
||||
|
||||
# token from https://github.com/settings/tokens
|
||||
OAUTH_TOKEN="[PUT YOUR TOKEN HERE BETWEEN THE QUOTES]"
|
||||
# where should the files be saved
|
||||
BACKUP_PATH="/volume1/serverBackups/github/backup"
|
||||
|
||||
|
||||
# you shouldn't need to change anything below here - unless you have over 100 repos: in which case, see the bottom.
|
||||
|
||||
API_URL="https://api.github.com/user/repos?type=all&per_page=100"
|
||||
GIT="/volume1/@appstore/git/bin/git"
|
||||
|
||||
fetch_fromUrl() {
|
||||
echo "Fetching from ${API_URL}"
|
||||
REPOS=`curl -H "Authorization: token ${OAUTH_TOKEN}" -s "${API_URL}" | jq -r 'values[] | "\(.full_name),\(.private),\(.git_url),\(.has_wiki)"'`
|
||||
for REPO in $REPOS
|
||||
do
|
||||
REPONAME=`echo ${REPO} | cut -d ',' -f1`
|
||||
PRIVATEFLAG=`echo ${REPO} | cut -d ',' -f2`
|
||||
ORIGINALGITURL=`echo ${REPO} | cut -d ',' -f3`
|
||||
HASWIKI=`echo ${REPO} | cut -d ',' -f4`
|
||||
GITURL="${ORIGINALGITURL/git:\/\/github.com\//git@github.com:}"
|
||||
mkdir "${BACKUP_PATH}/${REPONAME}" -p
|
||||
REPOPATH="${BACKUP_PATH}/${REPONAME}/code"
|
||||
|
||||
|
||||
if [ -d "$REPOPATH" ]; then
|
||||
echo "PULLING Repo URL: ${REPONAME} from url ${GITURL} to ${REPOPATH}"
|
||||
cd ${REPOPATH}
|
||||
${GIT} pull
|
||||
else
|
||||
echo "CLONING Repo URL: ${REPONAME} from url ${GITURL} to ${REPOPATH}"
|
||||
${GIT} clone ${GITURL} ${REPOPATH}
|
||||
if [ "true"===${PRIVATEFLAG} ]; then
|
||||
`touch ${BACKUP_PATH}/${REPONAME}/private`
|
||||
fi
|
||||
fi
|
||||
if [ "true"===${HASWIKI} ]; then
|
||||
WIKIPATH="${BACKUP_PATH}/${REPONAME}/wiki"
|
||||
WIKIURL="${ORIGINALGITURL/git:\/\/github.com\//git@github.com:}"
|
||||
WIKIURL=`echo ${WIKIURL} | sed -e "s/.git$/.wiki.git/"`
|
||||
if [ -d "$WIKIPATH" ]; then
|
||||
echo "PULLING Repo Wiki: ${REPONAME} from url ${WIKIURL}: to ${WIKIPATH}"
|
||||
cd ${WIKIPATH}
|
||||
${GIT} pull
|
||||
else
|
||||
echo "CLONING Repo Wiki: ${REPONAME} from url ${WIKIURL}:to ${WIKIPATH}"
|
||||
${GIT} clone ${WIKIURL} ${WIKIPATH}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
fetch_fromUrl
|
||||
# If you need additional urls adding, put them here.
|
||||
#API_URL="https://api.github.com/user/repos?type=all&per_page=100&page=2"
|
||||
#fetch_fromUrl
|
||||
Reference in New Issue
Block a user