I have started using the rsync tool to backup data from Raspberry Pi's SD card. The command I use is:
sudo rsync -aAHXv --delete --exclude-from=/home/pi/rsync-exclude.txt / /media/pi/PI_BACKUP/
based on the excellent stackexchange post by @goldilocks here.
I can see that
rsync clones the directory structure on my SD card. When it comes to restoring from the backup, I have a few points that I struggle with and seek clarity upon.
- Restoring a file or directory is the part that I am most comfortable with. I can use the rysnc tool to backup and restore my work (documents, images, scripts, etc.) without a problem. But will it work to restore installed software?
- I have software like GNU Radio installed from the software repository with the built-in package manager on Raspbian (Buster). This software is time-consuming to install. I have read that "everything is a file in Linux ." Further, I have read that the built-in package manager will add files in a standard location, such as
/opt. Does this mean that including these folders in the back-up copy of the root file-system is sufficient by itself to restore the software in the event of corruption (without the need for reinstallation)?
- Some of the software is installed outside of the package manager. For example, I have Arduino IDE installed. Since everything is a file in Linux, will this software also be reinstalled simply by including the folders where software is installed in the back-up copy of the root file-system?
There is also this solution proposed in a linux journal that appears to suggest the entire system can be backed-up and restored with rsync. I struggle to understand how this will work in practice with Raspberry Pi. My interpretation is when the Pi's SD card gets corrupted, do the following:
- Boot the Pi from a USB stick (not supported by all models of Pi.)
- Mount the (corrupt) SD card and the back-up medium.
- Restore the root folder with all its contents from the back-up medium to the original SD card with rysnc.
And presto! The corrupted card springs back to life as if nothing happened, all software and data intact. Is my understanding correct? What if the original is damaged beyond redemption? I am a beginner at best when it comes to linux and grateful for any help.