git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to backup git

From
Daniel Barkalow <barkalow@iabervon.org>
Date
May 12, 2008, 21:19 UTC
Message-ID
<alpine.LNX.1.00.0805121647540.19665@iabervon.org>
In-Reply-To
<48285087.3090402@gmail.com>
On Mon, 12 May 2008, bill lam wrote:
Show 8 quoted lines
> Johannes Schindelin wrote:
> > > I'd rsync just the .git directory.
> 
> Thanks to all responders for quick reply. I still have a related question. svn
> has a hotcopy command to ensure integrity so that it is possible to backup
> without shutting down the svn server. If someone update the .git while I am
> performing backup using tar or rsync? Will the atomicity of that commit still
> preserve in my backup copy?

There's the risk that the backup will start, it will copy all of the objects, then a git commit happens, which adds more objects (after rsync has passed) and updates a "refs" entry to refer to one of them, and then rsync copies the "refs" directory.

It's likewise possible to have part of the information for a commit copied and part of it not. This commit will be clearly broken, however (one or more objects not found).

So, essentially, every commit goes through the stages of not at all written, partially written but invalid, and valid and correct. Independantly, which commit is the latest is updated atomically. It's possible for an ill-timed backup to get a branch updated to a commit that's not yet valid in the backup. In you restored from this, you'd need to use one of several methods (mainly reflogs) to get back to the last valid commit that got backed up.

On the other hand, git will never, even in this sort of backup, end up with a commit that's valid but not completely correct.

	-Daniel
*This .sig left intentionally blank*
Previous: Jakub NarebskiNext: Junio C Hamano
Message 19 of 21 in “how to backup git”
  1. bill lamMay 12, 2008
  2. Tobias SarnowskiMay 12, 2008
  3. Sverre Hvammen JohansenMay 12, 2008
  4. Eric HanchrowMay 12, 2008
  5. Johannes SchindelinMay 12, 2008
  6. bill lamMay 12, 2008
  7. Miklos VajnaMay 12, 2008
  8. Johannes SchindelinMay 12, 2008
  9. Heikki OrsilaMay 12, 2008
  10. Johannes SchindelinMay 12, 2008
  11. Heikki OrsilaMay 12, 2008
  12. Johannes SchindelinMay 12, 2008
  13. Heikki OrsilaMay 12, 2008
  14. Heikki OrsilaMay 12, 2008
  15. Tim HarperMay 12, 2008
  16. Heikki OrsilaMay 12, 2008
  17. Sverre RabbelierMay 12, 2008
  18. Jakub NarebskiMay 12, 2008
  19. Daniel BarkalowMay 12, 2008
  20. Junio C HamanoMay 12, 2008
  21. Daniel BarkalowMay 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.