Backup Your Git Repository: Lazy Man Method

Intro

You don’t need to learn or use Github for “simple” Git repository backups 😎

This method only backs up the repository itself, it is not a valid Disaster Recovery Strategy.

If the folder you are backing up to is on the same disk and your original repo, and the disk itself fails…you’re still up a creek without a paddle.

If you are trying to implement Disaster Recovery for your repo, make the sure the folder/volume/mount-point/whatever you are backing up to, is itself, being backed up “offline”.

“Offline” meaning a separate disk/thumb drive/Dropbox/whatever.. 😁

However, this method is great for quickly backing up your repo if you want to experiment and test git techniques.

It’s always wise to do a quick backup before you put on the lab coat:

Image Credit: https://www.carlroth.com/com/en/protective-gowns/protective-gowns-kimtech-science-a7-lab-coat/p/2146.1

Solution

Here are the steps I took to do a local backup of my git repository:

# cd to the folder of your Git Repo
mkdir /tmp/bashScripts
cp -r .git/ /tmp/bashScripts
cd /tmp/bashScripts
git restore *

Full Demo

Leave a comment