This page shows you how to put your backup directories into a git repository as historical commits.
Suppose you have several backup dirs like this:
web_backup_2012-03-07 web_backup_2012-06-03 web_backup_2012-06-21 web_backup_2012-06-25 web_backup_2012-07-02 web_backup_2012-07-15 web_backup_2012-07-21
Now you want to put them on git, where each backup is a history commit. What's the best way? (each backup is about 1.1 G, 20k files.)
① cd to the oldest dir.
② then do:
git init git add -A git commit -m "Backup ‹date›." git tag "‹date›"
Now, it'll create a 〔.git〕 dir in it.
③ Move the 〔.git〕 dir to the second dir. cd to it. Then do:
git add -A git commit -m "Backup ‹date›." git tag "‹date›"
④ Repeat.
Here's a bash script to do it:
#!/bin/bash git init GIT_DIR=$(pwd) for dir in $(find . -maxdepth 1 -name web_backup_\* | sort); do pushd $dir git add -A git commit -m "Backup for $dir." git tag $dir popd done
This answer is provided by Jeff Bowman. Thanks Jeff.
Reference: 〔retro create a git repository from backup dirs By Jeff Bowman. @ stackoverflow.com…〕