With all the tweaks, updates and options we have with PiAware (mutability, FR24 feeders etc), I’m sure a lot of people will want to try these out, but dont want to risk “hosing” their current PiAware setup.
Being a PC-man, my knowledge of command-line Linux is limited.
So, if I wanted to make a complete image of my current PiAware SD card - that could just be rewritten to the SD if I trash the install - BUT do this over my (wired) network - Pi’s in the attic - what’s the best way of doing this?
Each Pi runs the following (cron) script twice a week to make a backup and then copy the backup to the server in the closet (I do a local backup then copy to the server so that I get a complete backup even if the server is unavailable). I also run it before I’m about to try something exciting that I may want to back out of… The backup file has the Pi host name and a date stamp. You do give all your Pis different host names, don’t you?
The script assumes you have a (root level) directory /backups – this one also skips mounted servers /sheep and /pigs
(mea culpa, mea culpa, mea maxima culpa – if you have suggestions on how to make this better, I’m open to them!)
(warning: this doesn’t work with “noobs” installs, as they do funky paritioning)
# K6RTM 2014/07/17 back up raspberry pi and copy the backup to server volume /sheep/rpibackups
# using the $HOSTNAME for the backup file
# insure we have a server connection, it's in fstab
sudo mount -a
# put us in the backups directory
# remove old backups (dangerous, I know)
echo "Snuff old backups..."
sudo rm *.gz
# capture our startup time
# capture date for date-stamping the backup file
# start doing the backup
echo "Starting backup to $_bfile..."
tar -zcpf "$_bfile" --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups --exclude=var/swap --exclude=sheep --exclude=pigs .
# done, let 'em know
printf "Backed up in %3d minutes.
# capture time again for copying to server
# copy the backup file to the server
echo "Copying $_bfile to $_sfile"
sudo cp "$_bfile" "$_sfile"
printf "Copied to server in %3d minutes.
Save this as something like backups.sh in the /backups directory. make sure it’s executable. It excludes a number of system things, as well as the backups directory and specific mounted volumes – otherwise it will try and back up anything and everything you have mounted. This usually takes a long time and fails when the SD card in your Pi fills up…
If you have 5 gigs used on your SD card, this can take up to an hour – be patient. The Pi 2 is faster!