Skip to content

Instantly share code, notes, and snippets.

@shubham1172
Created December 8, 2019 11:40
Show Gist options
  • Save shubham1172/84cceed92d19dd5e829a596f436182e9 to your computer and use it in GitHub Desktop.
Save shubham1172/84cceed92d19dd5e829a596f436182e9 to your computer and use it in GitHub Desktop.
Backup dotfiles
#!/bin/sh
# This script helps me update my dot files regularly
# It exists in my anacrontab as:
#
# @daily 10 setup.backup su -c /home/shubham1172/setup/scripts/backup.sh - shubham1172 >> /home/shubham1172/.anacronlogs 2>&1
cd ${HOME}/setup/
BACKUP=${HOME}/setup/scripts/backup
timestamp() {
date +"%d-%m-%Y at %T"
}
grep -v '^$\|^\s*\#' $BACKUP | while read -r line; do
echo "$line" | awk '{ system("rsync " $1 " " $2) }'
done
if [[ `git status --porcelain` ]]; then
git pull origin master
git add .
git commit -m "automatic update: $(timestamp)"
git push origin master
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment