Skip to content

Instantly share code, notes, and snippets.

@jellebens
Created June 8, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jellebens/5c3d80dbbf8eeebbb0ae908b8c9e9f42 to your computer and use it in GitHub Desktop.
Save jellebens/5c3d80dbbf8eeebbb0ae908b8c9e9f42 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Script to backup the SD card of a Pi to the nas.
backupLocation="/dev/athena/backup/openhabpi/"
backupName="$(date +%Y%m%d%H%S).img"
sudo dd if=/dev/mmcblk0 | sudo gzip > $backupLocation$backupName.gz
result=$?
if [ $result=0 ];
then
ls -d -1tr $backupLocation*.img.gz | head -n -3 | xargs -d '\n' rm;
exit 0;
fi;
if [ $result=1 ]; then curl -F "AuthorizationToken=xxx" -F "Body=Backup of openhabpi failed" https://pushalot.com/api/sendmessage; exit 0; fi;
ls -d -1tr $backupLocation*.img.gz | head -n -3 | xargs -d '\n' echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment