Skip to content

Instantly share code, notes, and snippets.

@flyinprogrammer
Created December 17, 2018 17:13

Revisions

  1. flyinprogrammer created this gist Dec 17, 2018.
    15 changes: 15 additions & 0 deletions repo_backup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/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
    14 changes: 14 additions & 0 deletions repo_restore.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/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