Backing up the Gateway?

I have not found “making a backup” in the documentation. How I can make regular backups so that when my SD card goes bad, I can get a clone up and running as quickly as possible?

See: Export local data to move the gateway to another machine

Hi @jharris,
One idea is, once you are sure you have added all your add-ons and devices into your gateway…you can use software like Win32 disk imager to “read” your SD card to an image file and store it in your PC/laptop or cloud like shown below. Later in case your SD card goes bad, you can “write” this image into your new SD cards of same size as before and this will turn your gateway up at the earliest with all your added devices and settings. Note that, here you are completely taking a backup of your entire raspberry pi image which includes OS, all the libraries you have installed and so on.

bckup

It’s a manual process, However I am not sure whether the entire image backup can be done on a regular interval automatically…it will be even more flexible…!!

Other idea is, you can just take a backup of your “.mozilla-iot” folder in you PC/laptop and burn the new SD card with mozilla’s pre-installed gateway image and scp the “.mozilla-iot” to your pi home directory later to restore your gateway settings as mentioned by @mrstegeman in the earlier comment …!! Thanks

This is what I’m currently using: I have cron job running at 3:45am every day run this: #!/bin/bash
#
#set -x
#
#D=echo
#
RETPD=30
DATE=`date +%Y%m%d%H%M`
DEST=/export/backup/gateway
#
$D sudo systemctl stop mozilla-iot-gateway.service
$D zip -q -r $DEST/mozilla-iot-gateway.$DATE.zip /home/pi/.mozilla-iot
$D sudo systemctl start mozilla-iot-gateway.service
$D find $DEST -type f -name ‘mozilla-iot-gateway.*.zip’ -mtime +$RETPD -exec rm -f {} ; 2>/dev/null
#
exit 0

RETPD= number of days to retain
/export/backup/gateway is an nfs mount from an external pc server

3 Likes

This method imo is the best, but I use Linux for my home PC. WinSCP might work just as well. I dunno. I use crontab with this setting:
30 2 * * * scp -r pi@192.168.254.156:~/.mozilla-iot ~/homeautomation/mozillaiot/

one piece of advice, since I just got done restore from an SDHC card failure. Backup both /home/pi/.mozilla-iot-gateway and /home/pi/mozilla-iot-gateway. Saves heartburn.

/home/pi/mozilla-iot/gateway is part of the standard image, so there should be no need to back that up.

A couple reasons. You can fall back to an earlier version of the gateway if an upgrade causes problems. Also depending on where plugins get installed, you will want to keep them in sync with the data.

Doing a manual copy requires to either shut down the gateway to copy data from the microSD on a different machine or knowing how to do ssh to the gateway. It would be nice if there was a backup and restore area in the UI where you could pull down a .zip (or similar) and restore from a file like that.