Backing up / Imaging PiAware SD card remotely?


Hi guys,

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?



Check out for making TAR (compressed) backups of your Pi.

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
cd /backups
# remove old backups (dangerous, I know)
echo "Snuff old backups..."
sudo rm *.gz
# capture our startup time
T="$(date +%s)"
# capture date for date-stamping the backup file
_now=$(date +"%Y-%m-%d")
# 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
T="$(($(date +%s)-T))"
printf "Backed up in %3d minutes.
" "$((T/60))"
# capture time again for copying to server
T="$(date +%s)"
# copy the backup file to the server
echo "Copying $_bfile to $_sfile"
sudo cp "$_bfile" "$_sfile"
T="$(($(date +%s)-T))"
printf "Copied to server in %3d minutes.
" "$((T/60))"

Save this as something like 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!

restore is easy–

cd /
sudo tar -zxvpf /backups/

and reboot when it completes.

bob k6rtm


Thanks Bob- looks good!

I only have the Rpi (everything else in te house is PC based, or Android).

Found this, which uses DropBox to copy everything to - which seems ideal (as my RPi already has it’s own wired-network connection. … -tutorial/

However, I was originally looking for a way to remotely image the RPi SD card - so I could completely “rebuild it” by a simple re-install of the image if needed.

Looking at the above, I’ll compare this with yours to work out what folders etc to copy.

Will study over the weekend, posted for others’ interest…


Just found this, which looks to create an image over the network (started locally from the Pi, pushed to a network location).

Am looking at pushing this image from my Pi to my PC in the first instance. … s-running/

Will have a look at this myself over the weekend.

(Of course, if one of you linux guru’s on here could build that into a cronjob, that would be perfect!).


If you want to do a sd card to sd card image, look for rpi-clone, which does just that – copies your SD card to an SD card attached to a USB port.

When I do this, I try and make the system as quiescent as possible, stopping other processes and services.