我目前正在开展一项任务,该任务应该备份所有AWS Codecommit存储库(目前大约有60个存储库),并将它们放在另一个AWS账户中的S3存储桶中。
我已经搜索了它,以找出这方面的可能性,但没有找到最符合我要求的。
1。) 使用代码管道进行考虑:
We can configure AWS CodePipeline to use a branch in an AWS CodeCommit
repository as the source stage for our code. In this way, when you make
changes to your selected branch in CodePipeline, an archive of the
repository at the tip of that branch will be delivered to your CodePipeline
bucket.
But, I had to neglect this option as it could be applied only to a
particular branch of a repository whereas I want a backup for 60
repositories all at a time.
2。) 考虑使用简单的git命令来克隆git 存储库,将克隆的东西放入文件夹并将它们发送到S3 另一个帐户中的存储桶 。
I had to neglect this because it complicates my process when a new git
repository is created where I need to manually go to AWS account and get the
url of that repo to clone.
所以,我想知道是否有一个很好的选择来自动备份位于不同AWS账户的S3中的Codecommit存储库。如果任何repos中的某些内容发生更改,它应自动触发该更改的部分并将其移至S3。
答案 0 :(得分:1)
以下是我要解决的问题,
<强>步骤:强>
这是我能想到的最快的备份。
对于自动存储库创建,您可以使用list-repositories, http://docs.aws.amazon.com/cli/latest/reference/codecommit/list-repositories.html
如果repo不存在,请克隆一个新的或更新现有的。
您还可以将git导出到单个文件,并在S3上启用版本控制后备份该文件。这会在每次运行时增加备份时间。
答案 1 :(得分:0)
完全理解这个线程很旧,但我只是在修改 EventBridge 触发器以在任何存储库上提交,这个事件对我有用,然后可以设置目标:
{
"source": ["aws.codecommit"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventSource": ["codecommit.amazonaws.com"],
"eventName": ["GitPush"],
"requestParameters": {
"references": {
"commit": [{
"exists": true
}]
}
}
}
}
从那里,迭代所有存储库以克隆,然后(在我的情况下)git bundle
,然后将包移动到存档位置...