问题描述
我想知道是否有一种简单的方法,即像简单的cron作业一样,定期将从远程git存储库中拉出来作为本地只读镜像用于备份目的?
理想情况下,它会拉出所有分支和标签,但主/主/头就足够了。
我只需要一种方法确保如果主git服务器死亡,我们有一个备份位置,我们可以手动故障切换到。 创建一个镜像
git clone --mirror [email protected]:repo.git
$ c
$ b 然后设置一个像这样的cron作业:
* / 1 * * * * gitbackup cd /backup/repo.git&& git fetch -q --tags
这会每分钟备份一次变更集。也许你不想经常这样做。
I am wondering if there is an easy way, ie like a simple cron job, to regularly pull from a remote git repository to a local read only mirror for backup purposes?
Ideally it would pull all branches and tags, but the master/trunk/head would be sufficient.
I just need a way to make sure that if the master git server dies, we have a backup location that we could manually fail over to.
解决方案 First create a mirror with
git clone --mirror [email protected]:repo.git
then setup a cron job like this:
*/1 * * * * gitbackup cd /backup/repo.git && git fetch -q --tags
This will backup the changesets every minute. Maybe you want to do this less frequently.
这篇关于通过拉动镜像一个git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!