Rsyncing git repo 足够好的备份解决方案吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9335079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is Rsyncing git repo good enough backup solution?
提问by DavidW
I often backup my laptop to an external hard drive. Is rsyncing git repos over good enough backup solution or are there any problems with this method?
我经常将笔记本电脑备份到外部硬盘驱动器。rsyncing git repos 是通过足够好的备份解决方案还是这种方法有任何问题?
采纳答案by FauxFaux
rsync
is a good solution for this. It may be a good idea to run git gc
and git repack
(neither with any arguments) before doing your backup; this may significantly reduce the number of files, and increase the chance of the data not changing too much by next time. Neither will lose any data.
rsync
是一个很好的解决方案。在进行备份之前运行git gc
和git repack
(不带任何参数)可能是个好主意;这可能会显着减少文件数量,并增加下次数据不会发生太大变化的机会。两者都不会丢失任何数据。
See http://sethrobertson.github.com/GitBestPractices/#backupsfor a write-up of why doing this with git isn't such a good solution.
请参阅http://sethrobertson.github.com/GitBestPractices/#backups以了解为什么使用 git 执行此操作不是一个好的解决方案。
回答by VonC
rsync is interesting if you really want to backup everything (including hooks and private files).
However:
如果您真的想备份所有内容(包括挂钩和私有文件),rsync 会很有趣。
然而:
- it doesn't guarantee the integrityof your repo once sync'ed (ie is git still working from the rsync'ed repo?)
- it has a higher probability of data corruption(you have to save many many files)
- 一旦同步,它就不能保证你的 repo的完整性(即 git 仍然在 rsync 的 repo 中工作?)
- 它有更高的数据损坏概率(您必须保存许多文件)
A nicer (and cleaner) solution would be to use git bundle(which is essentially a bar repo seen as onefile).
You update your local bundle, and save rsync it to your remote media.
Except that, this time, you only "rsync" (actually a simple copy is enough) one file.
And you can directly clone or pull from that one file, that bundle.
一个更好(更干净)的解决方案是使用git bundle(它本质上是一个被视为一个文件的 bar repo )。
您更新本地包,并将 rsync 保存到远程媒体。
除此之外,这一次,您只需“rsync”(实际上一个简单的副本就足够了)一个文件。
你可以直接从那个文件中克隆或拉出那个包。
回答by gmoney
I have a repo I keep on hosting that I push to. If I want to work somewhere I clone it, push changes back when I'm done.
我有一个我继续托管的回购协议。如果我想在克隆它的地方工作,请在完成后将更改推回。
You could rsync it too, but I found it easier to clone a repo out and then use it as my main dev spot. I think using one tool might be easier, but your mileage may vary.
你也可以 rsync 它,但我发现克隆一个 repo 并将其用作我的主要开发点更容易。我认为使用一种工具可能更容易,但您的里程可能会有所不同。