How to backup git server? When git server is broken, How can I push my local repository to a new git server?
Asked
Active
Viewed 1.3k times
2 Answers
12
You can use:
That way:
- you have only one file to move to a backup server
- you actually can use this file as an "origin" repo from which you can pull/push data like a regular Git repo.
You will for the first backup create a full bundle:
$ git bundle create /tmp/foo-all --all
-
1I think neither cloning, bundling or any other git command will get everything (for example the server side hooks). If you want to be sure to get everything a normal file based copy of the server repository directory would be needed. – Zitrax Jun 13 '16 at 08:51
-
@Zitrax I agree. hooks are not meant to be gotten or backed up within the same git archive, because they can be local to where the repo is used. I would back them up separately. But if those hooks are not an issue, a tar of the all repo would be enough indeed. – VonC Jun 13 '16 at 09:19
2
You back it up like any other server, just mirror the files; git stores its metadata in files like anything else. If you move the repository to a new machine, you need to change your local repository's origin to point to it. In .git/config
you'll find something like:
[remote "origin"]
url = SOMETHING
Change SOMETHING
to the address of your new server

Michael Mrozek
- 169,610
- 28
- 168
- 175
-
thanks a lot! and How to set my backup files become a new git server and keep the git log before? – Jackson May 20 '10 at 03:04