Github backup
Here is a script to create local snapshots for Github repos. It's always nice to have one for good measure.
It requires github-backup
to be installed:
brew install github-backup
#!/usr/bin/env bash
set -e -x
# Github repos will be cloned in subdirectories here
GITHUB_BACKUP_PATH=~/github-backup
# Archived repo snapshots will live here
ARCHIVE_PATH=~/Yandex.Disk.localized/
CURRENT_DATE=$(date +%Y%m%d-%H%M%S)
function backup() {
echo "---> $1/$2"
github-backup \
--incremental \
--repository $2 \
--repositories \
--token $GITHUB_BACKUP_TOKEN \
--output-directory $GITHUB_BACKUP_PATH/$1/$2 \
--starred \
--followers \
--following \
--issues \
--issue-comments \
--pulls \
--pull-comments \
--pull-commits \
--pull-details \
--labels \
--wikis \
--gists \
--private \
--fork \
--releases \
$1
ARCHIVE_FILE=$ARCHIVE_PATH/$CURRENT_DATE/$CURRENT_DATE-$1-$2.tar.gz
mkdir -p $ARCHIVE_PATH/$CURRENT_DATE
tar --verbose -cz -f $ARCHIVE_FILE $GITHUB_BACKUP_PATH/$1/$2
}
# Usage: backup <username-or-organization> <repo-name>
backup dreikanter notes
# Add more repos here
Upload backup files to the cloud with rclone
:
rclone sync --verbose=3 --interactive $ARCHIVE_PATH remote:github-backup