mseninc / github-gitlab-backup

Backup GitHub repos to on-premise GitLab
0 stars 0 forks source link

AWS リポジトリバックアップ #13

Closed kenzauros closed 3 months ago

kenzauros commented 4 months ago
flowchart LR

%% グループとサービス
Github[GitHub]:::OtherElement
Slack[Slack]:::OtherElement
Github -->|リポジトリ一覧取得| LambdaFunctions
LambdaFunctions -->|Slack通知| Slack

subgraph AWSCloud[AWS]
    subgraph RegionTokyo[東京リージョン]
        subgraph GroupLambda[Lambda]
            LambdaLayer1("Lambda Layer<br>Github (octokit)"):::AWSCompute
            LambdaFunctions[[Lambda<br>Functions]]:::AWSCompute
        end
        subgraph GroupStepFunctions[Step Functions]
            StateMachineSyncTask("ステートマシン<br>SyncTask"):::AWSCompute
            StateMachineBatchWorker("ステートマシン<br>BatchWorker"):::AWSCompute
        end
        subgraph GroupECR[ECR]
            RepoSyncImage("コンテナーイメージ<br>RepoSync"):::AWSCompute
        end
        subgraph GroupECS[ECS]
            TaskDefinitionRepoSync("タスク定義<br>RepoSync"):::AWSCompute
            TaskDefinitionRepoSync -.- RepoSyncImage
        end
        subgraph VPC[VPC]
            subgraph SubnetPublic1[Public Subnet 1]
                subgraph GroupECSCluster[ECS クラスター]
                    TaskRepoSync("タスク<br>RepoSync"):::AWSCompute
                end
                EC2Instance("EC2 Instance<br>(確認用)<br>Amazon Linux 2023"):::AWSCompute
            end
            subgraph SubnetPrivate1[Private Subnet 1]
                EFSMountTarget{{"EFS<br>マウントターゲット"}}:::AWSNetwork
            end
        end
        subgraph GroupEFS[EFS]
            EFSAccessPoint{{"EFS<br>アクセスポイント"}}:::AWSNetwork
            EFSFileSystem[("EFS<br>ファイルシステム")]:::AWSStorage
        end
        LambdaFunctions -.-|参照| LambdaLayer1
        StateMachineBatchWorker -->|呼び出し| LambdaFunctions
        StateMachineBatchWorker -->|呼び出し| StateMachineSyncTask
        StateMachineSyncTask -->|タスク実行| TaskDefinitionRepoSync
        TaskDefinitionRepoSync -->|タスク実行| TaskRepoSync
        EC2Instance -->|アクセス| EFSMountTarget
        TaskRepoSync -->|アクセス| EFSMountTarget
        EFSMountTarget --> EFSAccessPoint
        EFSAccessPoint --> EFSFileSystem
    end
end

%% ---スタイルの設定---

%% デフォルトスタイル
classDef default fill:none,color:#666,stroke:#aaa

%% AWS Cloudのスタイル
classDef AWSCloud fill:none,color:#345,stroke:#345
class AWSCloud AWSCloud

%% Regionのスタイル
classDef AWSRegion fill:none,color:#59d,stroke:#59d,stroke-dasharray:3
class RegionTokyo AWSRegion

%% VPCのスタイル
classDef AWSVPC fill:none,color:#0a0,stroke:#0a0
class VPC AWSVPC

%% Availability Zoneのスタイル
classDef AWSAZ fill:none,color:#59d,stroke:#59d,stroke-width:1px,stroke-dasharray:8
class GA AWSAZ

%% Private subnetのスタイル
classDef AWSPrivateSubnet fill:#def,color:#07b,stroke:none
class SubnetPrivate1 AWSPrivateSubnet

%% Public subnetのスタイル
classDef AWSPublicSubnet fill:#efe,color:#092,stroke:none
class SubnetPublic1 AWSPublicSubnet

%% Network関連のスタイル
classDef AWSNetwork fill:#84d,color:#fff,stroke:none

%% Compute関連のスタイル
classDef AWSCompute fill:#e83,color:#fff,stroke:none

%% DB関連のスタイル
classDef AWSDatabase fill:#46d,color:#fff,stroke:#fff

%% AWSStorage関連のスタイル
classDef AWSStorage fill:#493,color:#fff,stroke:#fff

%% 外部要素のスタイル
classDef OtherElement fill:#aaa,color:#fff,stroke:#fff
kenzauros commented 3 months ago

5/19 の実行でエラーが出ている

20240520_131244

20240520_131514

なぜか git fetch でエラーが出ている。

確認用インスタンスを起動して確認してみる。

と思ったが、インスタンスがなかった(デプロイ忘れ)ので、再デプロイ

yamada@ubuntu:~/github-gitlab-backup$ cd aws-github-backup/
yamada@ubuntu:~/github-gitlab-backup/aws-github-backup$ npx serverless deploy --stage prod --config 03_ec2.yml

特に問題なくいけてしまった。

sh-4.2$ bash
[ssm-user@ip-172-30-7-113 bin]$
[ssm-user@ip-172-30-7-113 bin]$ ll /mnt/efs
total 0
[ssm-user@ip-172-30-7-113 bin]$ mount_efs
[ssm-user@ip-172-30-7-113 bin]$ cd /mnt/efs/a20-03-jim-system
[ssm-user@ip-172-30-7-113 a20-03-jim-system]$ git --version
git version 2.40.1
[ssm-user@ip-172-30-7-113 a20-03-jim-system]$ git fetch
fatal: detected dubious ownership in repository at '/mnt/efs/a20-03-jim-system'
To add an exception for this directory, call:

        git config --global --add safe.directory /mnt/efs/a20-03-jim-system
[ssm-user@ip-172-30-7-113 a20-03-jim-system]$ git config --global --add safe.directory "$(pwd)"
[ssm-user@ip-172-30-7-113 a20-03-jim-system]$ git fetch
Username for 'https://github.com': kenzauros
Password for 'https://kenzauros@github.com':
remote: Enumerating objects: 278, done.
remote: Counting objects: 100% (150/150), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 278 (delta 135), reused 141 (delta 132), pack-reused 128
Receiving objects: 100% (278/278), 741.71 KiB | 5.01 MiB/s, done.
Resolving deltas: 100% (204/204), completed with 54 local objects.
From https://github.com/mseninc/a20-03-jim-system
 * [new branch]          2817-06-fix-import-shien-kubun-from-csv        -> origin/2817-06-fix-import-shien-kubun-from-csv
 * [new branch]          2817-06-fix-shien-kubun-dgv-column             -> origin/2817-06-fix-shien-kubun-dgv-column
   9e5db9ed9..534901d9a  2824-02-kyomu-add-wait-cursor                  -> origin/2824-02-kyomu-add-wait-cursor
 * [new branch]          2873-01-fix-iraibun-for-2025                   -> origin/2873-01-fix-iraibun-for-2025
   6f45690a5..7122ce298  61-kaikei-shiharai-fix-yosan-show-when-no-data -> origin/61-kaikei-shiharai-fix-yosan-show-when-no-data
   610a57173..737d3369c  62-kaikei-kouenkai-input-shiwake               -> origin/62-kaikei-kouenkai-input-shiwake
 * [new branch]          62-kaikei-kouenkai-main                        -> origin/62-kaikei-kouenkai-main
   bc67477ea..0603ac9dc  master                                         -> origin/master

Step Functions でももう一度実行するといけた