Auto Pi Backup to NAS
How to backup your PI as an image to a NAS.
Set up CIFS Mount
Mount CIFS (common internet file system)
sudo mount -t cifs //192.168.0.181/PIBackup /media/sd/backup/ -o user=user
Mount on Boot
Using fstab is a bit risky, instead add a script in say root eg:
mountNAS.sh:
add the mount command with password={pwd}
sleep 30
# time for network to come up
mount -t cifs //192.168.0.181/PIBackup /media/sd/backup/ -o user=user,password=pwd
then crontab -e and @reboot /root/mountNAS.sh
chmod +x mountNAS.sh
crontab -e
@reboot /root/mountNAS.sh
Backup
Framps tools
Using the following:
https://www.linux-tips-and-tricks.de/en/raspberry/303-pi-creates-automatic-backups-of-itself/
Once downloaded run
Chose dd/windows rather than rsync.
See: https://www.linux-tips-and-tricks.de/en/quickstart-rbk/
Cron is here:
/etc/cron.d/raspiBackup
#
# Crontab entry for raspiBackup.sh
#
# (C) 2017-2019 framp at linux-tips-and-tricks dot de
#
# Create a backup once a week on Sunday morning at 5 am (default)
#
00 03 * * 0 root /usr/local/bin/raspiBackup.sh
The above does a weekly backup on Sunday at 3.00 am.
Manually test:
nohup /usr/local/bin/raspiBackup.sh &
Restore
For DD backups the Windows32DiskImager can be used to restore the backup. A backup can also be restored with Raspberry Pi.
TAR or RSYNC backups have to be restored with Raspberry Pi.
For mac you can use the following to restore the image to SD card:
Originally published at https://blog.ramjee.uk on August 12, 2020.