尝试在另一个 AWS 账户的 S3 存储桶中备份 Codecommit 存储库 [英] Trying to have a backup of Codecommit repos in S3 bucket of another AWS account

查看:35
本文介绍了尝试在另一个 AWS 账户的 S3 存储桶中备份 Codecommit 存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在执行一项任务,该任务应该备份所有 AWS Codecommit 存储库(目前大约有 60 个存储库)并将它们放在位于另一个 AWS 账户的 S3 存储桶中.

我在谷歌上搜索了它以找出解决此问题的可能性,但没有找到最适合我的要求.

1.) 考虑使用代码管道:

我们可以配置 AWS CodePipeline 以使用 AWS CodeCommit 中的分支存储库作为我们代码的源阶段.这样,当你使对您在 CodePipeline 中所选分支的更改,这是该分支顶端的存储库将被传送到您的 CodePipeline桶.但是,我不得不忽略这个选项,因为它只能应用于存储库的特定分支,而我想要 60 的备份一次所有的存储库.

2.) 考虑使用简单的 git 命令来克隆 git存储库,将克隆的内容放入文件夹并将它们发送到 S3另一个帐户中的存储分区.

我不得不忽略这一点,因为当一个新的 git存储库已创建,我需要手动转到 AWS 帐户并获取要克隆的存储库的 url.

所以,我想知道是否有一个很好的选择来自动备份位于不同 AWS 账户的 S3 中的 Codecommit 存储库.如果任何存储库中的某些内容发生更改,它应自动触发更改的部分并将其移至 S3.

解决方案

这是我要解决的方法,

步骤:

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

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

对于自动存储库创建,您可以使用列表存储库,

I am currently working on a task which should take a backup of all AWS Codecommit repositories (around 60 repositories at the moment) and place them in an S3 bucket located in another AWS account.

I have googled it to find out the possibilities around this but found nothing that best suites my requirement.

1.) Considered using Code Pipeline:

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.) Considered doing it using simple git command which clones the git repositories, placing the cloned stuff into a folder and sending them to S3 bucket in another account.

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.

So, I want to know if there is a good option to automatically backup Codecommit repositories in S3 located in a different AWS account. If something in any of the repos changes, it should automatically trigger that changed part and move it to S3.

解决方案

Here is how I would solve,

Steps:

  1. Create a CodeCommit Trigger under AWS CodeCommit Repository
  2. Listen on EC2 on Jenkins or a node express or any http app
  3. Get all latest commits from repo
  4. aws s3 sync . s3://bucketname

This is the fastest backup I can think of.

For Automatic Repository Creation, you can use list-repositories, http://docs.aws.amazon.com/cli/latest/reference/codecommit/list-repositories.html

if repo does not exist already, clone a new one or update the existing one.

You can also do git export to a single file and back that file with a versioning enabled on S3. This will increase backup time everytime it runs.

这篇关于尝试在另一个 AWS 账户的 S3 存储桶中备份 Codecommit 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆