Created
April 10, 2016 16:03
-
-
Save TheCodeDestroyer/3a763de04980331a650a414ffbadb23c to your computer and use it in GitHub Desktop.
Raspberry Pi backup script (shell)
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 | |
| echo "Specify block device name:" | |
| read BLOCK_DEVICE_NAME | |
| echo "Is this the correct device: /dev/$BLOCK_DEVICE_NAME (Y/n)" | |
| read ANSWER | |
| if [ "$ANSWER" == "n" ]; then | |
| exit 0 | |
| fi | |
| IMG_SIZE="$(sudo blockdev --getsize64 /dev/$BLOCK_DEVICE_NAME)" | |
| echo "Type of backup: (GZIP/img)" | |
| read BACKUP_TYPE | |
| if [ "$BACKUP_TYPE" == "img" ] | |
| then | |
| sudo dd bs=4M if=/dev/$BLOCK_DEVICE_NAME | pv --rate --bytes --progress --size $IMG_SIZE --eta | dd of=raspbian.img | |
| else | |
| sudo dd bs=4M if=/dev/$BLOCK_DEVICE_NAME | pv --rate --bytes --progress --size $IMG_SIZE --eta | gzip > rasbian.img.gz | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment