- Mount the external device automatically, here it is a NAS available at the address/path
//CL-NAS/homemounted to/backup. Add following line to/etc/fstab:
//CL-NAS/home /backup cifs defaults,rw,credentials=/etc/nas-credentials,x-systemd.automount 0 0
To mount a usb device instead, have a look at this
This will keep the external device mounted at the specified location, even after reboots and crashes.
- Add a credential file at
/etc/nas-credentials:
username=****
password=****
-
Add the backup script to perform and manage the backups. As a standard, at most the last 5 backups are kept before deleting them. This can be changed in the script. Look at file
backup.shfor more information. -
Add a cron job to execute the backup script periodically.
To edit the cron tab:
sudo crontab -e
Add following line:
0 1 * * 0 /backup/backup.sh >> /var/log/cron.log 2>&1
And now you should have automatic backups of your Raspberry Pi!