9

Today I created my first shell script for automation.

I have a git repository I use for backing up documents at the training centre I'm at for work. Not a specific project, just all of the documents and miscellaneous stuff. The need for this came about because they re-image the computers every month with a new version of windows (Because they're too cheap to register windows). And I can't risk forgetting to copy all the files onto my USB drive the day before they re-image.

So at the end of each day I open a git bash and type:
git add .
git commit -m "Backup - dd/mm/yy"
git push

Not a particularly laborious task but repetitive and time consuming.
So I decided to create a .sh script to automate the process
(The idea originally occurred because of this post: https://devrant.com/rants/329221/...)

So after about half an hour fiddling about with dates and $ signs, I came up with GitBackup.sh:
git add .
today=$(date '+%d-%m-%y')
commitMsg="Backup - "$today
git commit -m "$commitMsg"
git push origin master

Not much but proud to call it my first automation script.

Comments
Add Comment