Skip to content

Instantly share code, notes, and snippets.

@uuklanger
Created December 24, 2016 06:00
Show Gist options
  • Save uuklanger/ecfb510d4895fda1d96e0ff4e7119297 to your computer and use it in GitHub Desktop.
Save uuklanger/ecfb510d4895fda1d96e0ff4e7119297 to your computer and use it in GitHub Desktop.
Assuming you have a repository
#!/bin/bash
# (c)2016 KenWare
#
PROJECTS_FILE=$HOME/projects.list
REPO_DIR=/opt/data/git/repositories
BACKUP_LOCATION=/opt/backups/git_backups
CURRENT_DATE=`date +"%Y%m%d%H%M%S"`
for repo in `cat ${PROJECTS_FILE}` ; do
TARGET_ZIP=${CURRENT_DATE}"_"`echo ${repo}| sed "s/[\/\.]/_/g"`".tar.gz"
echo "REPOSITORY: "${REPO_DIR}/${repo}
echo "TARGET....: "${BACKUP_LOCATION}/${TARGET_ZIP}
tar zcfv ${BACKUP_LOCATION}/${TARGET_ZIP} ${REPO_DIR}/${repo}
echo "====================================================================="
done
echo "Backing up GIT Home...."
tar zcfv ${BACKUP_LOCATION}/${CURRENT_DATE}"_home_git.tar.gz" /home/git
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment