My cronjob backup system for my bash configuration files

I use three files to configure my bash shell: .bash_profile, .bashrc, and .bash_alias. I occasionally change these files but rarely remember to record the changes in my backup gist. So I decided to make a cronjob that would automatically back up these three files.

First, the backup script

The following script does three things:

  1. Copies the actual .bash_profile, .bashrc, and .bash_alias files to a GitHub gist repo
  2. Commits and pushes the changes to GitHub
  3. Displays a native Apple notification that the process was run

Second, the cronfile

The script must be executed automatically. Ideally I would run the script on boot, but I didn’t want to make the effort for the script to wait until an internet connection was formed. My solution was to push changes to GitHub three times a day. When I worked more consistent hours, I only pushed changes once a week when I knew I would be coding at work.