Reputation: 11
I am trying to perform a backup on a local git repo to another location on my git server. I've seen many posts and articles about either putting github backups to the cloud to github repos hosted by githu backed up locally. Here, I'm merely trying to back the local server git repo to another location on the server. This is a unix server.
Upvotes: 1
Views: 108
Reputation: 21
There is a very simple to use python tool that automatically backs up organisations' repositories in .zip format by saving public and private repositories and all their branches. It works with the Github API, if you want to re-download from github the repositories on a server, the tool will be very useful : https://github.com/BuyWithCrypto/OneGitBackup
Upvotes: 1
Reputation: 124844
Working with local clones is very similar to working with remote ones. As the "url" of such "remotes", you can use filesystem paths.
Let's say your project is at /path/to/repo1
, and you want to create a backup under /backups
.
Here's one way to do it:
cd /path/to/repo1
git clone --bare . /backups/repo1.git
git add remote backup /backups/repo1.git
git push backup
This creates a bare repository at /backups/repo1.git
that's a perfect clone of the original. You can update the backup with:
cd /path/to/repo1
git push backup
However, since the original repository is "aware" of its backup, when you do a git branch -r
, it will show the duplicate branches on the backup
remote, which might be too much clutter.
Another way:
git init --bare /backups/repo1.git
cd /backups/repo1.git
git remote add origin /path/to/repo1
git remote update
This way the backup is aware of the original repo, and not the other way around. You can update the backup with:
cd /backups/repo1.git
git remote update
Upvotes: 0