Last active
September 25, 2020 10:28
-
-
Save maciekish/dc1f9372916eacf06efe10aa6e9469cd to your computer and use it in GitHub Desktop.
Backup Pi SD Card to Samba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Usage bash <(curl -Ls https://gist.githubusercontent.com/maciekish/dc1f9372916eacf06efe10aa6e9469cd/raw) | |
if [ `whoami` != 'root' ] | |
then | |
echo "You must be root to do this." | |
exit | |
fi | |
if [ -z "$1" ] | |
then | |
echo "Please specify block device to backup as first argument. Usually this is /dev/mmcblk0 on Raspbian." | |
exit | |
fi | |
umount /mnt/backup | |
mkdir /mnt/backup | |
mount -t cifs -o user=maciekish //10.0.1.0/backup /mnt/backup | |
size=$(blockdev --getsize64 $1) | |
echo "Backing up $1 ($size bytes)" | |
dd bs=4M if=$1 | pv --size $size | gzip > /mnt/backup/sdcard.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment