I have moved my source control on git,and now i want to take the backup of my remote repository on a regular basis. Can anyone help me with the batch script for taking the backup of Remote repositories on GIT??
2 Answers
Assuming you created your repository as git init --bare
- All you need to do to backup it, is to regularly backup that directory. Same way you backup any other directory.
Alternatively, you can create a script that clones the repository every X time to a different location.

- 13,146
- 5
- 30
- 48
Often a backup of a git repository is simply another git repository. You can set it up initially using git clone --mirror
:
--mirror
Set up a mirror of the source repository. This implies
--bare
. Compared to--bare
,--mirror
not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by agit remote update
in the target repository.
Per the above and this SO question, further updates can be made simply by running git remote update
on the target (backup) repository.
Though you can also do a simple directory backup using scp
or rsync
, cloning the repository allows git to determine which objects need to be sent over, whereas filesystem tools (or other git-naive options) may need to re-hash and compare more state.

- 1
- 1

- 90,959
- 16
- 217
- 251