Making backup copies of our Raspberry Pi

Well a quick post, I leave you a little bit of the way I usually use to make security cups or backups of the Raspberry Pi that we have in our environment, it is well known that the evil that lurks in them is the corruption of SD cards, So before you have any surprises, it is always good to have an updated image of our Pi or its content.

The ideal will always be to make an offline copy, This is, you take out the SD and put it in a computer and clone it to an image file, either with dd on Linux or Mac or with Win32DiskImager on Windows, But, well, that is the ideal and as long as we remember it will be good to do it. But what happens the rest of the time? I leave you two ways that I usually use, a first one to make remote images (Complete) of the Raspberry, and a second of its content, this is files or folders that we are interested in, incrementally.

A good tip can be to try to minimize that it is written on an SD Card, you know that Raspberrys have a habit and record LOGs constantly or swap playing records… To avoid this I recommend you This post. By the way, to make these copies in an automated way without having to enter credentials, We will copy the public key of our computer where we will make the copies to the remote computers, If you have doubts, Check out This post.

Remote Image Backup

From a central machine that I have on Linux, In a bash script I usually throw this example:

Sh pi@DIRECCION_IP_RASPBERRY "sudo dd if=/dev/mmcblk0 bs=1M | gzip -" | dd of=/PATH_DONDE_DEJAR_LA_COPIA/FICHERO_IMAGEN_RASPBERRY.gz

This will make us an identical image of your Raspbian in a compressed file, eye, It should be emphasized that perhaps these copies are not stable, it will depend on several reasons, but personally to this day I have restored backups of this type without surprises, when a Raspberry 'dies', I just unzip this backup and turn it back to a new SD, Pi starts and doesn't even know, And everything comes back to its being.

Incremental Copy

Well, something simple is usually using Rdiff-backup, a server/agent software that will allow us to make a backup copy of any folder or file that contains a Raspberry, So we installed it on all remote Raspberry Pi, as well as on the machine from which we are going to make the copies, by means of:

sudo apt-get install rdiff-backup -y

And now, we can simply try it out, indicating which Raspberry and which directory we want to copy to where:

rdiff-backup pi@DIRECCION_IP_RASPBERRY:/home/pi/ /mnt/SYNOLOGY/NOMBRE_RASPBERRY/home/

Well, I hope it has been useful to you and you can have everything under control and thus never lose any data! Thank you as always for sharing on social 😉 networks

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!