Since we are supposed to do a lot of tweaking and tinkering with our Raspberry Pi installations, it is always a good idea to backup the working SD card image before venturing for any experimentation. One way to do this is to take the whole SD card out and use another Windows/Mac computer to backup and restore the full sd-card image as demonstrated earlier. To save you with this much hassle, here we are with another method to perform automated "hot backups" from a Raspberry Pi itself to an external USB disk drive or remote storage. Simply use the provided Shell script and enjoy fast, efficient and automated RPi backups.
Just save the below shared Shell script (use right-click and "save as" this link) on your RPi and execute using sudo ./Raspberry_Pi_Backup_Script.sh
. This script disables the "tar" compression command from the original version as it takes "too much" time on our little Pi, to get back that functionality simply uncomment the two relevant lines.
Comments
Restore script
Any chance you could show how to restore a backup made with this?
Restore
When I needed a restore it was harder then I thought due to lack of another linux computer, you will need to google for how to restore dd images. This also came very handy for me - http://www.megaleecher.net/Working_With_Linux_Created_DD_Images_On_Windows for getting data back from image on a windows computer.
Backup Completed
It seems to work fine.
Thank you so much for the script. It's exactly what I was looking for.
Removal of old files
I know this is old now, but thank you SO MUCH! It has saved me lots of time in trying to do one myself :D One thing for anyone running this; Line 67 needs changing as we are no longer compressing the file:
rm -f $DIR/backup_*.tar.gz
rm -f $DIR/backup_*.img
Backup works fine
Thank you very much for this script.
On my Raspberry Pi 3 the backup process completes succesfully.
EXCELLENT
This was just awesome, run and working like a charm on my Raspi 2. Thanks a lot for sharing!!
Image too big for SD card
I tried your backup script and the backup itself runs fine but now I try to restore the image but the image is bigger than the SD card. What do I miss?
Same problem for me
Same problem for me
Add new comment