Created
June 16, 2012 08:33
-
-
Save naiquevin/2940530 to your computer and use it in GitHub Desktop.
Setting up and maintaining Git repository mirrors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## This shell script will read all names from repos.txt | |
## which are names of git repositories located at | |
## git@main-reposerver:/path/to/repos | |
## if a mirror is not created, it will create | |
## | |
## other wise it will try to update the mirror | |
## | |
## Main purpose of having mirrors is backup so pushing | |
## changes to main repo is disabled by default. To enable | |
## it, uncomment the two lines below | |
for repo in `cat repos.txt` | |
do | |
rdir="/home/git/mirrors/$repo" | |
if [ -d $rdir ]; then | |
echo "Mirror for $repo found.." | |
echo "Fetching updates from main repo.." | |
`cd $repo && git remote update` | |
# echo "Pushing updates to main repo" | |
# `cd $repo && git push --mirror` | |
else | |
echo "Mirror for $repo not found.." | |
echo "Creating a mirror.." | |
`git clone --mirror git@main-reposerver:/path/to/repos/$repo` | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment