Skip to content

Instantly share code, notes, and snippets.

@joshfreemanIO
Created August 5, 2014 01:15
Show Gist options
  • Save joshfreemanIO/c82ca9d91aae4cd934de to your computer and use it in GitHub Desktop.
Save joshfreemanIO/c82ca9d91aae4cd934de to your computer and use it in GitHub Desktop.
Backup all repositories
#!/bin/sh
# Backup of git directories
DIRECTORIES=(
"/Users/josh/EncFS-Decrypted/Finances"
);
DATE=`date -u`;
# For each directory in the directories array,
# change to that directory, stage the files, commit
# the files and push
for DIRECTORY in "${DIRECTORIES[@]}"; do
# If the directory change fails, continue the loop
if ! cd $DIRECTORY &> /dev/null; then
echo "$DIRECTORY is unreachable";
continue;
fi
# Backup
git add . &> /dev/null;
git commit -m "Backup on $DATE" &> /dev/null;
git push &> /dev/null;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment