Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
upload-cloud

GitHub Action

Github Migrations Backup

1.0.0

Github Migrations Backup

upload-cloud

Github Migrations Backup

Backup a Github Org with one Action

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Github Migrations Backup

uses: skrepr/[email protected]

Learn more about this action in skrepr/github-backup-action

Choose a version

skrepr_logo

Github Backup Action

Releases LICENSE Issues PR Commits Stars Forks

About

This GitHub Action allows you to backup and archive a organization repository to an S3 Bucket with the help of the GitHub Organization migrations API

Requirements

The Migrations API is only available to authenticated organization owners. For more information, see "Roles in an organization" and "Other authentication methods."

Github Action example config

    - name: Github Org Backup
      uses: skrepr/[email protected]
      env:
        GH_ORG: ${GITHUB_ACTOR}
        GH_APIKEY: ${GITHUB_TOKEN}
        GH_REPO: ${GITHUB_REPOSITORY}
        AWS_BUCKET_NAME: "your-bucket-here"
        AWS_BUCKET_REGION: "eu-west-1"
        AWS_ARN: "arn:aws:s3:::your-bucket-here"
        AWS_ACCESS_KEY: ${AWS_ACCESS_KEY} # Github Secret is advised
        AWS_SECRET_KEY: ${AWS_SECRET_KEY} # Github Secret is advised

AWS policy for S3 bucket user

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket-here"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket-here/*"
            ]
        }
    ]
}

Recovering your repositories from the archive

Github migrations only archives your .git from every repository.

To recover your code from the archive:

  1. Place all the repo.git files in a .git folder.
  2. Execute the command git init
  3. After Git has reinitialized the project, execute git reset --hard HEAD

License

MIT / BSD

Author Information

This Github Action was created in 2022 by Jeroen van der Meulen, commisioned by Skrepr