3

我目前正在处理一项任务,该任务应该备份所有 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。

4

2 回答 2

2

这是我将如何解决,

脚步:

  1. 在 AWS CodeCommit 存储库下创建CodeCommit 触发器
  2. 在 Jenkins 或 node express 或任何 http 应用程序上收听EC2
  3. 从 repo获取所有最新提交
  4. aws s3 同步。s3://bucketname

这是我能想到的最快的备份。

对于自动存储库创建,您可以使用列表存储库, http://docs.aws.amazon.com/cli/latest/reference/codecommit/list-repositories.html

如果 repo 尚不存在,请克隆一个新的或更新现有的。

您还可以将 git 导出到单个文件并在 S3 上启用版本控制的情况下返回该文件。这将增加每次运行时的备份时间。

代码提交备份

于 2017-09-20T02:49:01.113 回答
0

完全感谢这个线程是旧的,但我只是在修改一个 EventBridge 触发器以提交任何 repo,这个事件对我有用,然后可以设置目标:

{
  "source": ["aws.codecommit"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["codecommit.amazonaws.com"],
    "eventName": ["GitPush"],
    "requestParameters": {
      "references": {
        "commit": [{
          "exists": true
        }]
      }
    }
  }
}

从那里,迭代所有 repos 以克隆,然后(在我的情况下)git bundle然后将包移动到存档位置......

于 2021-05-30T21:43:54.860 回答