Skip to content

Instantly share code, notes, and snippets.

@aquatix
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aquatix/10249476 to your computer and use it in GitHub Desktop.
Save aquatix/10249476 to your computer and use it in GitHub Desktop.
Convert a directory with backup tarballs to a Git repository
#!/bin/bash
if [ -z "$1" ]; then
echo "Missing source directory (dir with the tarballs)"
echo "usage:"
echo " tarball2git.sh <backupdir> <gitrepo>"
elif [ -z "$2" ]; then
echo "Missing git repository directory"
echo "usage:"
echo " tarball2git.sh <backupdir> <gitrepo>"
else
for FILE in `ls -1 $1`; do
#echo $FILE
echo "./$1/$FILE"
echo "$2/$FILE"
cp -a "$1/$FILE" $2
cd $2
tar xf "$FILE"
rm "$FILE"
git add -A
git commit -am "$FILE"
cd -
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment