Auto Update Backup
The goal here is to get a network connected Raspberry Pi to periodically update and backup itself up to an external device or network share.
The step to getting this work are.
This is heavily based on the developments presented here [1]
- install the script
- create a backup location
- setup the script for your system
- enable the script in cron.
Contents
Installation
Copy the script to the mhome folder on your Raspberry Pi using wget.
cd ~ wget https://github.com/martinrgmiller/RPiAutoBackup/blob/master/AutoUpdateBackup.sh
Create a Backup Location
This location must not be on the Pi's SD card, it should be an external USB drive or other share on your network
Backup SD Image Accessing Network Shares
create a directory
sudo mkdir /media/cifshares
Secondly, mount the location that will receive the backup:
sudo mount -t cifs //hostname/sharename -o username=xxxx,password=yyyy /media/cifshares
Setup the script
The header of the script contains the user defined parameters
# Setting up directories SUBDIR=raspberrypi_backups DIR=/hdd/$SUBDIR
Modify these to match the location for the backup folder previously created. For example change DIR=/hdd/$SUBDIR
to DIR=/media/cifshares/sharename/$SUBDIR
Copy the script to for local admin control. This isn't strictly necessary as cron can run a script from anywhere, but its 'neater'.
sudo cp /home/jack/AutoUpdateBackup.sh /usr/local/bin/
Modifythe permission of the script to make it executable
sudo chmod +x /usr/local/bin/AutoUpdateBackup.sh
Setup Cron
Add the following line to /etc/crontab [2]
01 4 * * * root /home/jock/scripts/backup_usbhdd.sh
sudo