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

Re: Incremental Backup of repositories using Git

From
Jeff King <peff@peff.net>
Date
May 8, 2025, 18:39 UTC
Message-ID
<20250508183910.GB10864@coredump.intra.peff.net>
In-Reply-To
<SJ1PR19MB64010CDB3F21FE91C97E566BAE8BA@SJ1PR19MB6401.namprd19.prod.outlook.com>
On Thu, May 08, 2025 at 10:24:55AM +0000, Abhishek Dalmia wrote:
> I ran into an edge case while testing incremental backups with git
> bundle. If a commit is created with a timestamp earlier than the
> latest full or incremental backup, it can be excluded from the next
> bundle due to the --since parameter even if there is a buffer.

Yeah, I don't think you want to use "--since" here, since it is about commit timestamps. You care about the state of the refs at a particular time. Or more accurately, you care that you have captured a particular ref state previously.

So ideally you'd snapshot that state in an atomic way, feed it as the "current" state when doing a bundle, and then save it for later. You can easily create such a snapshot with for-each-ref, but I don't think git-bundle has a way to provide the exact set of ref tips and their values (it just takes rev-list arguments, and wants to resolve the refs themselves).

You could probably get away with just creating a bundle with the current state, and then pulling the snapshot values from the created bundle. Something like this:

  # for initial backup
  if ! test -e last-bundle-snapshot; then
    >last-bundle-snapshot
  fi
  # mark everything from last as seen, so we do not include it,
  # along with --all (or your choice of refs) to pick up everything
  # we have currently
  sed -e 's/^/^/' <last-bundle-snapshot |
  git bundle create out.bundle --all --stdin
  # and now save that ref state for next time; this is inherently
  # peeking at the bundle format.
  sed -ne '
	# quit when we see end of header
	/^$/q;
	# drop comments and old negatives; copy only first word (the oid)
	s/^\([^-#][^ ]*\).*/\1/p;
  ' <out.bundle >last-bundle-snapshot

Or alternatively, instead of using git-bundle at all, you could just store a collection of ref snapshots (from "for-each-ref") and thin packs (from "pack-objects --thin --stdout", fed from the old snapshot and the new). Which is really all that bundles are anyway.

-Peff
Previous: Abhishek DalmiaNext: Abhishek Dalmia
Message 6 of 14 in “Incremental Backup of repositories using Git”
  1. Akash SMay 5, 2025
  2. Justin ToblerMay 5, 2025
  3. Abhishek DalmiaMay 6, 2025
  4. Justin ToblerMay 6, 2025
  5. Abhishek DalmiaMay 8, 2025
  6. Jeff KingMay 8, 2025
  7. Abhishek DalmiaMay 27, 2025
  8. Michal SuchánekMay 8, 2025
  9. Jeff KingMay 8, 2025
  10. rsbecker@nexbridge.comMay 8, 2025
  11. Jeff KingMay 8, 2025
  12. Michal SuchánekMay 9, 2025
  13. Michal SuchánekMay 9, 2025
  14. Michal SuchánekMay 9, 2025

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.