Created
December 8, 2019 11:40
-
-
Save shubham1172/84cceed92d19dd5e829a596f436182e9 to your computer and use it in GitHub Desktop.
Backup dotfiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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