Skip to content

Instantly share code, notes, and snippets.

@DavidDobr
Created January 8, 2017 10:58
Show Gist options
  • Save DavidDobr/d8efb60af47e7a29a52583b929e8d488 to your computer and use it in GitHub Desktop.
Save DavidDobr/d8efb60af47e7a29a52583b929e8d488 to your computer and use it in GitHub Desktop.
Script to copy local config and settings files into a github repo
#!/usr/bin/env bash
HOME=$HOME
# DESTINATION_DIR is the github repo to save current user's settings to
DESTINATION_DIR="$HOME/code_projects/settings_backup/"
# This is a secondary Dropbox backup
REDUNDANT_BACKUP="$HOME/Dropbox/settings_backup"
function check {
# check if previous operation returned an error message
if [ "$?" = "0" ]; then
echo "Success!"
echo
else
echo "Cannot copy settings!" 1>&2
exit 1
fi
}
echo
echo "Pulling settings to $DESTINATION_DIR..."
cp -r $HOME/{.bashrc,.gitconfig,.pylintrc,.ssh,.vim,.vimrc} "$DESTINATION_DIR"
check
echo "Pulling config files to $DESTINATION_DIR..."
cp -r "$HOME/.config/terminator/" "$DESTINATION_DIR/config_files"
check
echo "Redundant backup in Dropbox..."
cp -r "$DESTINATION_DIR" "$REDUNDANT_BACKUP"
check
echo "Finished pushing settings to sync folder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment