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

Re: [PATCH v2 3/3] Documentation/git-bundle.txt: discuss naïve backups

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 2, 2024, 01:39 UTC
Message-ID
<xmqqzfmiza69.fsf@gitster.g>
In-Reply-To
<c50f9d405f9043a03cb5ca1855fbf27f9423c759.1730234365.git.code@khaugsbakk.name>
kristofferhaugsbakk@fastmail.com writes:
> +A naive way to make a full backup of a repository is to use something to
> +the effect of `cp -a <repo> <destination>`.  This is discouraged since
> +the repository could be written to during the copy operation.  In turn
> +some files at `<destination>` could be corrupted.
There is nothing wrong in the above, but ...
> +This is why it is recommended to use Git tooling for making repository
> +backups, either with this command or with e.g. linkgit:git-clone[1].

... "git bundle create - --all" in (or "git clone --mirror" from) a repository cannot be an equivalent to "cp -a" in a quiescent repository. You'd lose what is staged, you'd lose per repository configuration, you'd lose hooks, you may be losing other things I am not remembering.

IOW, those who uses what you call "a naive way" may be doing so with a valid reason.

So the patch is not quite correct as-is, even though it is going in the right direction. It discourages apples and recommends oranges.

Let me think aloud to see if I can come up with an improvement.
    It is tempting to do "cp -a <repository> <elsewhere>" or "tar cf
    - <repository>" to take a snapshot of a repository, but unless
    the repository is quiescent, you will get an incomplete snapshot
    with inconsiistent state.  If all you care about is the state of
    the objects and the refs that point to objects, you can instead
    use "git clone --mirror <repo> <elsewhere>" or "git bundle
    create <bndl> --all" to take a consistent snapshot.
    Note that you will lose other local states of the repository,
    such as the contents of the index, working tree, per-repository
    configuration, hooks, etc.
or something like that, perhaps?
Previous: kristofferhaugsbakk@fastmail.comNext: Taylor Blau
Message 20 of 37 in “Documentation/git-bundle.txt: promote --all for full backup”
  1. 0/4 Documentation/git-bundle.txt: promote --all for full backupkristofferhaugsbakk@fastmail.com, Oct 20, 2024
  2. 1/4 Documentation/git-bundle.txt: mention --all in Synopsiskristofferhaugsbakk@fastmail.com, Oct 20, 2024
  3. Kristoffer HaugsbakkOct 20, 2024
  4. Taylor BlauOct 21, 2024
  5. 2/4 Documentation/git-bundle.txt: mention full backup examplekristofferhaugsbakk@fastmail.com, Oct 20, 2024
  6. Taylor BlauOct 21, 2024
  7. Kristoffer HaugsbakkOct 22, 2024
  8. 3/4 Documentation/git-bundle.txt: mention --all in spec. refskristofferhaugsbakk@fastmail.com, Oct 20, 2024
  9. Taylor BlauOct 21, 2024
  10. 4/4 Documentation/git-bundle.txt: discuss naïve backupskristofferhaugsbakk@fastmail.com, Oct 20, 2024
  11. Taylor BlauOct 21, 2024
  12. Taylor BlauOct 22, 2024
  13. Kristoffer HaugsbakkOct 22, 2024
  14. 0/3 Documentation/git-bundle.txt: promote --all for full backupkristofferhaugsbakk@fastmail.com, Oct 29, 2024
  15. 1/3 Documentation/git-bundle.txt: mention full backup examplekristofferhaugsbakk@fastmail.com, Oct 29, 2024
  16. Junio C HamanoNov 2, 2024
  17. Kristoffer HaugsbakkNov 6, 2024
  18. 2/3 Documentation/git-bundle.txt: mention --all in spec. refskristofferhaugsbakk@fastmail.com, Oct 29, 2024
  19. 3/3 Documentation/git-bundle.txt: discuss naïve backupskristofferhaugsbakk@fastmail.com, Oct 29, 2024
  20. Junio C HamanoNov 2, 2024
  21. Taylor BlauOct 29, 2024
  22. 0/4 Documentation/git-bundle.txt: promote --all for full backupkristofferhaugsbakk@fastmail.com, Nov 7, 2024
  23. 1/4 Documentation/git-bundle.txt: mention full backup examplekristofferhaugsbakk@fastmail.com, Nov 7, 2024
  24. Junio C HamanoNov 8, 2024
  25. Kristoffer HaugsbakkNov 10, 2024
  26. Kristoffer HaugsbakkNov 12, 2024
  27. Junio C HamanoNov 12, 2024
  28. Kristoffer HaugsbakkNov 16, 2024
  29. 2/4 Documentation/git-bundle.txt: remove old `--all` examplekristofferhaugsbakk@fastmail.com, Nov 7, 2024
  30. 3/4 Documentation/git-bundle.txt: mention --all in spec. refskristofferhaugsbakk@fastmail.com, Nov 7, 2024
  31. 4/4 Documentation/git-bundle.txt: discuss naïve backupskristofferhaugsbakk@fastmail.com, Nov 7, 2024
  32. Junio C HamanoNov 7, 2024
  33. 0/4 Documentation/git-bundle.txt: promote --all for full backupkristofferhaugsbakk@fastmail.com, Nov 16, 2024
  34. 1/4 Documentation/git-bundle.txt: mention full backup examplekristofferhaugsbakk@fastmail.com, Nov 16, 2024
  35. 2/4 Documentation/git-bundle.txt: remove old `--all` examplekristofferhaugsbakk@fastmail.com, Nov 16, 2024
  36. 3/4 Documentation/git-bundle.txt: mention --all in spec. refskristofferhaugsbakk@fastmail.com, Nov 16, 2024
  37. 4/4 Documentation/git-bundle.txt: discuss naïve backupskristofferhaugsbakk@fastmail.com, Nov 16, 2024

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.