Skip to content

Instantly share code, notes, and snippets.

@Wingysam
Last active May 18, 2018 18:06
Show Gist options
  • Save Wingysam/8a7a602f952da4eac22c99c9a9baf012 to your computer and use it in GitHub Desktop.
Save Wingysam/8a7a602f952da4eac22c99c9a9baf012 to your computer and use it in GitHub Desktop.
cd ~
mkdir -p .bin
cd .bin
if [ -e backup.sh ]
then
if [ "$(md5 backup.sh)" != "MD5 (backup.sh) = afbf604d948a59292a0fefe2a0c913cc" ]
then
echo uh oh. backup.sh exists
exit 1
fi
fi
if [ -e backupall.sh ]
then
if [ "$(md5 backupall.sh)" != "MD5 (backupall.sh) = dd51aef83ce03ddc48ec3d72cf896303" ]
then
echo uh oh. backupall.sh exists
exit 1
fi
fi
curl -s https://ghostbin.com/paste/2xdgs/raw > backup.sh
curl -s https://ghostbin.com/paste/mh4eg/raw > backupall.sh
tempfile=$(mktemp)
crontab -l > $tempfile 2> /dev/null # Dirty hack for if no crontab exists
echo "0 * * * * /Users/$(whoami)/.bin/backupall.sh > /dev/null" >> $tempfile
crontab $tempfile
rm $tempfile
echo 'Done :D Should backup once per hour now'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment