{"id":21801750,"url":"https://github.com/tango-controls/githubbackup","last_synced_at":"2025-04-13T18:34:03.945Z","repository":{"id":54495377,"uuid":"76025731","full_name":"tango-controls/GitHubBackup","owner":"tango-controls","description":"A simple script to backup an organization's GitHub repositories with issues and wikis","archived":false,"fork":false,"pushed_at":"2021-02-15T16:42:59.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T09:12:32.727Z","etag":null,"topics":["backup","github","issues","organization","script","wiki"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tango-controls.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-09T10:25:36.000Z","updated_at":"2023-08-29T12:23:28.000Z","dependencies_parsed_at":"2022-08-13T17:50:12.753Z","dependency_job_id":null,"html_url":"https://github.com/tango-controls/GitHubBackup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tango-controls%2FGitHubBackup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tango-controls%2FGitHubBackup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tango-controls%2FGitHubBackup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tango-controls%2FGitHubBackup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tango-controls","download_url":"https://codeload.github.com/tango-controls/GitHubBackup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248760608,"owners_count":21157391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","github","issues","organization","script","wiki"],"created_at":"2024-11-27T11:19:48.209Z","updated_at":"2025-04-13T18:34:03.921Z","avatar_url":"https://github.com/tango-controls.png","language":"Shell","readme":"# GitHubBackup\nA simple script to backup an organization's GitHub repositories with their issues and wikis.\n\nThis script is adapted from https://gist.github.com/darktim/5582423 (which was forked from https://gist.github.com/rodw/3073987) to support proxy and to retrieve more than 30 issues and authentication via TOKEN.\n\nThe following environment variables can be defined to make this script fit to your needs:\n* GHBU_BACKUP_DIR: the directory where the backup files will be generated\n* GHBU_ORG: name of the GitHub organization whose repositories with issues and wikis will be backed up (default = tango-controls)\n* GHBU_GITHOST: GitHub hostname (default = github.com)\n* GHBU_TOKEN: GitHub API token (See https://help.github.com/articles/creating-an-access-token-for-command-line-use/ for more details)\n* GHBU_PRUNE_OLD: when true, backups older than GHBU_PRUNE_AFTER_N_DAYS will be deleted (default = true)\n* GHBU_PRUNE_AFTER_N_DAYS: the minimum age in days of backup files to delete (default = 3 (days))\n* GHBU_SILENT: when true, only shows error messages (default = false)\n* GHBU_API: base URI for the GitHub API (default = https://api.github.com)\n* GHBU_GIT_CLONE_CMD: base command to use to clone GitHub repositories (default = \"git clone --quiet --mirror git@${GHBU_GIHOST}:\")\n* GHBU_PROXY_SETTINGS: Proxy settings for curl command. For instance \"-x proxy.mydomain.com:1234\". (Default = \"\")\n\nScript requires jq; install with `apt install jq` on Ubuntu.\n\nThe script will generate per repository X from the target organization:\n* a tar.gz file containing the git repository X\n* a tar.gz containing the git repository of this X repository's wiki \n* a tar.gz containing a json file with all the issues of repository X\n\nThe git repositories are cloned with --mirror option so the result will be quite different from what we get after a classical git clone.\u003cBR\u003e\nTo get a working copy, in your current directory, of a repository which was saved by this backup script, one should extract the tar.gz containing the git repository backup and then execute the following command: \u003cBR\u003e `git clone /path/to/your/extracted/git/your_repository.git .`\n\nYou can use a cron job to run this script. One way to use this script is to create a .github_backuprc file in the home directory of the user which will run the cron, with rwx------ permissions (rwx only for the user since the GitHub API token will be saved into this file).\nThis file will look like the following:\n```\nexport GHBU_TOKEN=your_token_here\nexport GHBU_BACKUP_DIR=/where/you/want/your/backups\nexport GHBU_PROXY_SETTINGS=\"-x myproxy.mydomain.com:1234\"\nexport GHBU_PRUNE_AFTER_N_DAYS=5\n```\n\nHere is an example of a crontab you can use to execute the backup script every day at 09:00 am and send an e-mail once the script has completed its work:\n```\n#\n# Backup tango-controls GitHub organization\n#\n00 09 * * * . /home/my_username/.github_backuprc; /path/to/backup/script/backup-github.sh | mailx -s \"[cron-github-backup] tango-controls\" my_email_address@mydomain.com \u003e/dev/null 2\u003e\u00261\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftango-controls%2Fgithubbackup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftango-controls%2Fgithubbackup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftango-controls%2Fgithubbackup/lists"}