Git 作为远程备份和更新系统
我有一个远程设备,可以通过无线和间歇性链接访问它。 该设备记录每日数据,我希望能够以可靠的方式获取所有更新。 我想到使用 git 的目的:
- 我有一个定期工作,它将 git 提交远程上的所有日志
- 在本地服务器上,我会 git pull 任何新日志,以便底层协议能够处理原子性和连接的稳健性
但是,我仍然有一个问题:如何保持远程存储库“小”?我想以某种方式清除本地服务器上已经获得的修订,但将历史记录保留在本地服务器上。
我尝试使用 git 过滤分支并重新打包,但它会破坏任何克隆。我相信这与 git rebase --interactive 相同,但增加了需要手动编辑文件的问题(即更改 pick -> squash)。
也许每次都会创建新分支并删除它们?
I have a remote device which I access over a wireless and intermittent link.
The device logs daily data, and I'd like to be able to get all updates in a robust way.
I thought of using git for the purpose:
- I'd have a periodic job which would git commit all the logs on the remote
- At the local server, I'd git pull any new log, so that the underlying protocol would handle the atomicity and robustness of the connection
However, I still have an issue: how do I keep the remote repository "small"? I'd like to purge in some way the revisions which I already got on the local server, but keep the history on the local server.
I tried with git filter branch and repack, but it breaks any clones. I believe it is the same with git rebase --interactive, with the added issue of requiring manual editing of the file (i.e. changing pick -> squash).
Maybe creating new branches every time and deleting them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您担心耗尽远程系统上存储库的空间,那么我建议根本不要在远程系统上使用 Git。
也许考虑使用
rsync
在本地和远程系统之间进行同步。为了在本地系统上保留历史记录,您可以在每次 rsync 之后提交到本地系统上的 Git 存储库。这样,您就可以在本地系统上获得具有完整历史记录的备份,而在远程系统上则完全没有历史记录。If you are concerned about using up space for the repository on the remote system, then I would suggest not using Git on the remote system at all.
Maybe consider using
rsync
to sync between the local and remote systems. For keeping a history on the local system, you can then commit to a Git repository on the local system after eachrsync
. This way you have a backup, with complete history, on the local system and no history at all on the remote.Git 相当矫枉过正,因为您可以每天轮换日志文件并 rsync/scp 将它们删除,从而删除刚刚复制的文件(除了可能仍在写入的当前日志文件之外)。
Git is rather overkill, when you could just rotate the log files daily and rsync/scp them away, removing the files you've just copied (apart from the current log file, which might still be being written to).