Automate backups from Raspberry Pi 5 to a Raspberry Pi 3 NAS with SSH keys, proper permissions, an rsync
-based Bash script, and weekly scheduling via cron
.
Goal: back up the Automation directory from the Pi 5 to a Pi 3 NAS. Steps: generate SSH keys → copy the public key to the NAS → confirm key-based login → set directory permissions → write the backup script → make it executable → run it → verify on the NAS → schedule weekly.
4) Verify user context with whoami
.
Ensure the user referenced by the script can write to /mnt/nasdrive
on the NAS.
Open nano and create the script: set variables, check directory access, run rsync
with logging, and print success/fail status.