Created
December 17, 2018 17:13
-
-
Save flyinprogrammer/888efb8fe6013e6c16cb61279aee565a to your computer and use it in GitHub Desktop.
Scripts for backing up and restoring Git repositories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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