Mirror git repositories
Mirror git repositories!
This script is designed to backup a farm of git repositories in an automated fashion, it makes a local mirror that you can push on a remote.
Because a git repository can disappear, you may loose access to a source code, even if it’s Free/Libre. Large projects with a lot of developers can set up a new repository quickly if the former one is down. How about smaller projects? like this small piece of code you love so much but only a few are interested in?
The same way you backup your holiday pictures, copy your favorite FLOSS, because you have the right to do it! If github screws up, you’ll have your life vest.
pip install gitbackup
python setup.py install
On archlinux: https://aur.archlinux.org/packages/gitbackup/
Let’s start with a new sweet home
mkdir backup_github && cd backup_github
Initialize (create a .gitbackup directory that will contain a config file)
Add repositories (a name of your choice followed by the URL)
gitbackup clone sametmax_0bin https://github.com/sametmax/0bin.git
gitbackup clone carl_backupchecker https://github.com/backupchecker/backupchecker.git
Some time later, let’s synchronize 0bin
gitbackup pull sametmax_0bin
Or all the repositories
That’s it! Your local copy is updated. You can write a cron job :)
We can add a remote for some (or all!) repositories. For example:
gitbackup remote add sametmax_0bin email@example.com:mirror/bak_sametmax_0bin.git
Once you pulled to sync your copy, you can push
gitbackup push sametmax_0bin
Or, you can push all repositories for which a remote has been configured
Similarly to the pull and push commands
gitbackup sync sametmax_0bin
Without name, gitbackup will pull all repositories and push those with a remote
Move a mirror
gitbackup mv sametmax_0bin sametmax_0bin_source
Remove a remote
gitbackup remote rm sametmax_0bin