Back Up the Entire Operating System to the Cloud to Prevent SD Card Failure
I once had the situation where I suddenly woke up one day to find the entire smarthome system completely paralyzed because it could not boot back up. At that moment I wished I could immediately restore the system using the most recent backup file, but unfortunately the last time I ssh'd in to make a backup was 3 months earlier. By then the system had gone through a lot of changes, from software updates to all the configurations I had tweaked during use. I then spent half a day adjusting everything back to how I wanted it.
The article below is a set of solutions for automatically backing up and storing backup files in multiple locations so you can easily access and restore almost all of your data.
Refer to Mega’s direct guide.nz
Install disk backup
Show the list of disks: df -h
cd ~
git clone https://github.com/lzkelley/bkup_rpimage.gitInstall backup file shrinking
wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/binFix missing package error on arm64: Reference source
$ wget https://mega.nz/linux/repo/Raspbian_10.0/Release.key && sudo apt-key add Release.key
$ sudo dpkg --add-architecture armhf
$ sudo nano /etc/apt/sources.list.d/mega.nz.listthen pasting the indicated code below:
# Source Repository for Mega-CMD and Mega Desktop (For Raspbian ARM)`
# Updated Mega Repo with 4092 bit Release Key`
deb [arch=armhf] https://mega.nz/linux/repo/Raspbian_10.0/ ./Install mega-sync:
sudo apt update && sudo apt install megacmd
Log in to Mega
mega-login Email PASS
Set up synchronization
mega-sync /mnt/sda1/Backup /Backup
- View log:
mega-cmd-server --debug-full | tee megacmd.log - Grant write permission:
sudo chmod 775 /mnt/sda1/Backup
Run backup
sudo sh bkup_rpimage/bkup_rpimage.sh start -c /mnt/sda1/Backup/BPI-Backup-$(date +%Y-%m-%d).img & sudo pishrink.sh /mnt/sda1/Backup/BPI-Backup-$(date +%Y-%m-%d).img- Back up using the script from git
- Remove redundant parts to shrink the file
Manage files on Mega
mega-ls
mega-rm -r -f /Backup/BPI-Backup-$(date -d "7 days ago" +%Y-%m-%d).img