Full backup before updating

If I want to make a full backup so I can revert an update, would this be enough, or do I need to keep anything else?

sudo service homeassistant stop
sudo tar -czvf /bku/hass-`date +%Y%m%d_%H%M`.tgz /srv/homeassistant /home/homeassistant/.homeassistant
sudo service homeassistant start

This is with homeassistant being installed in the /srv/homeassistant virtualenv and the database is sqlite3 stored in .homeassistant

I have a Pi and what I usually do is shut it down and just image the SD card. It takes a lot longer, but if I do run into an issue, it’s drop dead easy to get back to a working config.

1 Like

Yeah, I do that aswell from time to time. Probably the best way to do it before upgrades.

This is what I do everytime after a stable updates/upgrades as well… but my Pi is in a case hanging on the wall… so it does take a bit of time to shut it down, take out the case and remove the card then backup the image, then put it back in.

I wish I could do a backup LIVE as it’s running… but I haven’t found a best way yet :slight_smile:

I have a cronjob, which saves the image of the card every sunday to my nas and another cronjob, which saves my .homeassistant-folder to my nas every day.

Would you share the way your PI images were made? and have you tried it on another card to make sure the backup image is good?

i Always make live imagebackup to a mounted windowsshare like this

sudo dd if=/dev/mmcblk0 of=/mnt/backupdir/rpibackup.img bs=1M

after a while i did put that in a shl file and put a date in the name and made a cronjob from it.

edit: i have used it twice already to get back to an old image on another card.
i even have changed from RPI2 to RPI3 with it.

Awesome, I’m going to try this.

Thanks.

Of course :slight_smile: I recovered the image back to the sd-card and it worked like it should. The only one issue is that the images have the same size like the card and the Windows-Application “Ester” says the card is smaller than the image. Win32Diskimager worked as it should.
I use the following commands:

sudo mount -t cifs -o username=<USERNAME>,password=<PASSWORD> //<IP OF YOUR SHARE>/<PATH TO YOUR SHARE> /media/backup/
sudo dd if=/dev/mmcblk0 | gzip > /media/backup/HASS04.05.17.img.gz

The first command mounts your network drive and the second makes the image, zips it and put it in the network drive.

@ReneTode this sounds like an excellent solution. However for some unknown reason my Windows machine does not see the rpi smb share. My MacBook pro sees it fine but my Windows 7 machine not (and as this runs 24/7 I would love to use that one. Is there anything specific on the win7 machine that needs to be done to see the share?

Maybe you should do the other way, mount the windows drive on your Pi… that’s what I did and I can access any folder on the drive.

i also use win32diskimager to write my cards.

i have my shares Always mounted at startup, because i have 3 backups in a cronjob.

  1. every 15 minutes i backup my data
  2. every day i backup my settings and pi dir
  3. every week i backup an image

@tyfoon i backup from the RPI to a windows machine. so i dont see a share from the RPI but i have a share on the PC (win 10) and the RPI uploads to that share.

by the way, for the partial backup i use:

sudo rsync -r --delete  --update '/home/pi' '/mnt/backup'

That gzip pipe is nice… that’d definitely help to keep the size of the image down.

Thanks for sharing.

For safeties I do a full image backup but on a nightly basis I am backing up my Pi and HASS home directories using Webmin, which is basically just a systems management web interface. Allows me to monitor stats, update packages, manage services, etc. Just all around great tool.

http://www.webmin.com/

1 Like