Add backup script for raspberry pi sd card
authorJulien Valroff <julien@kirya.net>
Sun, 13 Mar 2016 18:16:05 +0000 (19:16 +0100)
committerJulien Valroff <julien@kirya.net>
Sun, 13 Mar 2016 18:16:05 +0000 (19:16 +0100)
pi_backup [new file with mode: 0755]

diff --git a/pi_backup b/pi_backup
new file mode 100755 (executable)
index 0000000..efa0e2b
--- /dev/null
+++ b/pi_backup
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+BACKUP_DIR="/media/usb/pi_backup"
+
+if [ -w $BACKUP_DIR ]; then
+    dd if=/dev/mmcblk0 bs=4M | gzip > $BACKUP_DIR/pi-backup_$(date +"%y%m%d").img.gz
+    find $BACKUP_DIR -type f -name pi-backup_\*.img.gz -ctime +3 -exec rm \-f {} \;
+fi