Auto Update Backup

From SingletonMillerWiki
Revision as of 17:23, 19 May 2013 by Martin (Talk | contribs) (added wget link to installation)

Jump to: navigation, search


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]

  1. install the script
  2. create a backup location
  3. setup the script for your system
  4. enable the script in cron.

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

CIFS share

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 



References

  1. The Raspberry Pi Backup Thread
  2. how-do-i-add-jobs-to-cron-under-linux
  3. can-a-raspberry-pi-be-used-to-create-a-backup-of-itself