git リモートリポジトリをローカルにバックアップ

リモートリポジトリ消すってなときに
git clone とかしてきたら

current_branch=`git rev-parse --abbrev-ref HEAD`

git fetch
git fetch --prune

for remote_branch in `git branch -r`
do
     $remote_branch =~ ^origin/(.*)$ 
    branch_name=${BASH_REMATCH[1]}
    if [ $branch_name = $current_branch ]; then
        continue
    fi
    if [ ! $branch_name = 'HEAD' ]; then
        echo "checkout : $branch_name <- $remote_branch"
        git checkout -b $branch_name $remote_branch
    fi
done

git checkout $current_branch