This script allows a user to backup repos with commit history from organisations/users and compress them into a single zip archive
Dependancies:
jq git zip
-
Replace
<your access token>
with your access token from https://github.com/settings/tokens Token only needs repo and org read permisions. -
Replace
<your github user>
with your github user and setcloneUserRepos=
totrue
if your cloning a users repos or Replace<Your organiasation>
with a org name and setcloneOrgRepos=
totrue
. It is possible to set both totrue
this will clone both the user and the orgs repo into seperate folders in a single .zip -
Run the script with you might need to set the script to executable with
chmod +x ./cloneall.sh
./cloneall.sh
Restore notes borrowed from https://gist.github.com/xtream1101/fd79f3099f572967605fab24d976b179
Here we will restore the repo from the bundle and create a new remote origin that will contain all brnaches and tags
- Clone the repo from the bundle
git clone vuejs_vue.bundle
- Get all the branches locally to be pushed up to your origin later (from: https://gist.github.com/grimzy/a1d3aae40412634df29cf86bb74a6f72)
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
- Create a new repo on your git server and update the origin of the local repo
git remote set-url origin [email protected]/xtream1101/test-backup.git
- Push all branches and tags to the new remote origin
git push --all
git push --tags