Skip to content

Instantly share code, notes, and snippets.

@flyinprogrammer
Created December 17, 2018 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyinprogrammer/888efb8fe6013e6c16cb61279aee565a to your computer and use it in GitHub Desktop.
Save flyinprogrammer/888efb8fe6013e6c16cb61279aee565a to your computer and use it in GitHub Desktop.
Scripts for backing up and restoring Git repositories.
#!/bin/bash
set -e
BUNDLE_NAME=${1}
: "${BUNDLE_NAME:?Name of the bundle file should be the first argument.}"
REPO_URL=${2}
: "${REPO_URL:?URL of the repo to clone should be the second argument.}"
BUNDLE_FILE=$(pwd)/${BUNDLE_NAME}.bundle
pushd $(mktemp -d)
git clone --mirror ${REPO_URL} .
git bundle create ${BUNDLE_FILE} --all
popd
#!/bin/bash
set -e
BUNDLE_PATH=${1}
: "${BUNDLE_PATH}:?Full path to the bundle file should be the first argument.}"
RESTORE_URL=${2}
: "${RESTORE_URL}:?URL of the restore respistory destination should be the second argument.}"
pushd $(mktemp -d)
git clone --mirror ${BUNDLE_PATH} .
git remote add restore ${RESTORE_URL}
git push --mirror restore
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment