Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skrepr/github-backup-action
Github Action to backup a Github Organization
https://github.com/skrepr/github-backup-action
action backup github typescript utility
Last synced: 4 days ago
JSON representation
Github Action to backup a Github Organization
- Host: GitHub
- URL: https://github.com/skrepr/github-backup-action
- Owner: skrepr
- License: mit
- Created: 2022-06-07T07:39:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T14:38:42.000Z (8 months ago)
- Last Synced: 2024-10-14T12:34:14.248Z (about 1 month ago)
- Topics: action, backup, github, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 1.2 MB
- Stars: 10
- Watchers: 2
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
Github Backup Action
# 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](https://docs.github.com/en/rest/migrations/orgs#start-an-organization-migration)
# Requirements
The Migrations API is only available to authenticated organization owners. For more information, see "Roles in an organization" and "Other authentication methods."
Ensure that you have owner permissions on the source organization's repositories.
[Generate an access token](https://docs.github.com/en/[email protected]/articles/creating-an-access-token-for-command-line-use) with the `repo` and `admin:org` scopes on GitHub.com.
To minimize downtime, make a list of repositories you want to export from the source instance. You can add multiple repositories to an export at once using a text file that lists the URL of each repository on a separate line.# Commands
To build the project: `npm run build`
To watch project during developement: `npm run watch`
To run the script: `node dist/main.ts`
List all repos: `curl "https://api.github.com/orgs/skrepr/repos" \
-u 'username:'`
# Github Action example config## Create archive
```yaml
name: Backup repositorieson:
schedule:
- cron: '0 1 * * 0' # At 01:00 on Sundayjobs:
backup:
name: Create archive
runs-on: ubuntu-latest
timeout-minutes: 30steps:
- name: Github Migrations Backup
uses: skrepr/[email protected]
with:
github-organization: "your-organization-here"
github-apikey: ${}
aws-bucket-name: "your-bucket-here"
aws-bucket-region: "your-bucket-region-here"
aws-access-key: ${AWS_ACCESS_KEY} # Github Secret is advised
aws-secret-key: ${AWS_SECRET_KEY} # Github Secret is advised# Save migration.data.id as an artifact at the end of the first run
- name: Archive Data
uses: actions/upload-artifact@v2
with:
name: migration-data
path: migration_response.json
```## Download archive
```yaml
name: Download archiveon:
schedule:
- cron: '0 3 * * 0' # At 03:00 on Sundayjobs:
backup:
name: Download archive
runs-on: ubuntu-latest
timeout-minutes: 30steps:
# Download the migration.data.id as an artifact at the beginning of the second run
- name: Archive Data
uses: actions/download-artifact@v2
with:
name: migration-data
path: migration_response.json- name: Github Migrations Backup
uses: skrepr/[email protected]
with:
download-migration: true
github-organization: "your-organization-here"
github-apikey: ${}
aws-bucket-name: "your-bucket-here"
aws-bucket-region: "your-bucket-region-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
```json
{
"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](https://github.com/jeroenvandermeulen), commisioned by [Skrepr](https://skrepr.com)