3

We have a git server on our local server. I want to backup these git repositories from server side directly copying "repositoryname.git" folders.

In case of a problem with a new server is it possible to recover files from these folder? I think the files stored as fractured on an Object folder on this .git folders. And not directly accessible from server.

Thank you.

efegurkan
  • 47
  • 2
  • 9

1 Answers1

6

In order to backup bare repo from the server, you should avoid copying directly the repositoryname.git folder (which contains local config, including gitlab hooks), but rather do a git bundle (see my answer on git bundle).

 cd repositoryname.git
 git bundle create /tmp/repositoryname.bundle --all

That will generate one file, that you can easily copy around, and from which you can clone in order to restore that repo on another machine.

The .git/object folder will be re-populated once cloned, with the right objects.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250