npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

backghup

v1.1.0

Published

Tool for backing up all your data on GitHub using the migration API.

Downloads

7

Readme

backghup – Back up GitHub data using migrations

Tool for backing up all your data on GitHub using the migration API.

Backghup is a command-line tool that lets you export and download all your data stored on GitHub. It uses the migration API to create and retrieve migration archives that can contain the following data (see the API documentation for a full list):

  • Repositories
  • Issues, including comments
  • Pull requests, including comments
  • Commit comments
  • Attachments
  • Milestones
  • Projects and releases

Colorful illustration of a camera on a tripod pointing at a cloud in the sky

Backghup will download archives for your user account, as well as all organizations that you are an admin of (this is a limitation of the API). All repositories for the user or organization will be included in the archive.

You can run backghup multiple times and it will detect existing migrations and archives less than an hour old (can be disabled, see below) and not request and/or download them again.

Installation and usage

You can install backghup globally using yarn or npm:

yarn global add backghup
# or `npm install -g backghup`

Alternatively, you can run it directly with npx:

npx backghup [options]

To use backghup, you need to create an access token with the repo and read:org scopes.

Then, set the GITHUB_TOKEN environment variable to this access token:

export GITHUB_TOKEN=your-token-here

Finally, run backghup to create a new migration and download the archives:

backghup

This will download the archives for your user and organizations as .tar.gz files to the archives folder. You can change the output folder with the --out-dir option.

By default, backghup will check if there is an existing migration less than an hour old and if so, use that instead of creating a new one. You can force backghup to always create new migrations with the --force-new-migration flag.

You can also use the --exclude option to filter out specific users and organizations from being backed up, and the --exclude-repo option to filter out specific repositories from being backed up. These options take regular expressions as arguments and can be specified multiple times. The regular expressions have to match the full name of the user, organization (e.g. baltpeter) or repository (e.g. baltpeter/backghup), from start to end, to exclude it. They are case-insensitive. For example:

  • To exclude your own user account and any organization that ends with a number, you can use:

    backghup --exclude <your username> --exclude ".*[0-9]"
  • To exclude any repository from your user account that starts with js- and the repository baltpeter/backghup, you can use:

    backghup --exclude-repo "<your username>/js-.+" --exclude-repo baltpeter/backghup

Finally, you can use the --extract flag to extract the archives after downloading them. Note that this will overwrite/delete existing files from a previous run (it is mostly meant to be used in conjunction with an incremental backup software). Also, by default, the archives are deleted after extraction. You can disable that behaviour with the --keep-archives flag.

Use backghup --help to show the help:

Options:
  --help                 Show help                                     [boolean]
  --version              Show version number                           [boolean]
  --force-new-migration  By default, if there is an existing migration created
                         in the last hour, we’ll use that one instead of
                         creating a new one. With this flag, you can force a new
                         migration to always be created.
                                                      [boolean] [default: false]
  --out-dir              Directory to store the archives in.
                                                  [string] [default: "archives"]
  --exclude              A regex to filter out the user and/or specific
                         organizations (can be specified multiple times). The
                         regex has to match the full name of the user or
                         organization, from start to end, to exclude it (it will
                         be automatically enclosed in the ^ and $ anchors). It
                         is case-insensitive.              [array] [default: []]
  --exclude-repo         A regex to filter out specific repositories (can be
                         specified multiple times). This is run against the full
                         repository name (e.g. `baltpeter/backghup`). The regex
                         has to match the full name of the repository, from
                         start to end, to exclude it (it will be automatically
                         enclosed in the ^ and $ anchors). It is
                         case-insensitive.                 [array] [default: []]

Examples:
  backghup                                  Back up all your repositories,
                                            including the ones in organizations
                                            you are an admin of.
  backghup --out-dir ~/gh-backups           Back up everything, and store the
                                            archives in `~/gh-backups`.
  backghup --out-dir ~/gh-backups           Back up everything, and extract the
  --extract                                 downloaded archives into a
                                            subdirectory named after the user/
                                            organization in `~/gh-backups`.
                                            Afterwards, delete the archive
                                            files.
  backghup --extract --keep-archives        Back up everything and extract the
                                            archives, but don't delete the
                                            archive files after extraction.
  backghup --exclude baltpeter --exclude    Back up everything, but exclude the
  tweaselORG                                `baltpeter` user and the
                                            `tweaselORG` organization.
  backghup --exclude-repo                   Back up everything, except the
  baltpeter/backghup                        `baltpeter/backghup` repository.
  backghup --exclude "b.*" --exclude-repo   Back up everything, except
  "baltpeter/.*-config"                     repositories from users/
                                            organzations starting with a `b`,
                                            and repositories from the 
                                            `baltpeter` user that end with
                                            `-config`.

License

This code is licensed under the MIT license, see the LICENSE file for details.

Issues and pull requests are welcome! Please be aware that by contributing, you agree for your work to be licensed under an MIT license.