Automatic Backup of Configuration Files

ok @silvrr i real all with more attention and i can set the permission for homeassistant, now i can see the files on my SDcard.
Thanks again.

Checkout BitBucket.org - it is a GIT system with free private accounts. I use it all the time.

I create a doc on the site regarding backup to usb. With retention and checks if the usb drive is there etc… see https://home-assistant.io/docs/ecosystem/backup/backup_usb/

Created one for drop box too https://home-assistant.io/docs/ecosystem/backup/backup_dropbox/ although not perfect (it syncs all) it works.

2 Likes

I use a modified version of the script found [here] (https://www.raspberrypi.org/forums/viewtopic.php?p=136912) to backup the entire SD card. Works like a charm.
I have it set as a cron task each night to backup on my Synology NAS.

1 Like

I have moved to GIT because I think for the HA config files you need not just backup but also version control. There are some great automation examples on the forum.

Git is nice, but you cannot store your secrets in, you still need a backup for that too. A combination of github with secrets stored on a usb stick might be a good call. Also note that the usb_backup stores it daily, with a different name so it does take some sort of versioning into account. I do agree that sharing is one of the nicer things to do.

You could also use a local git repo on your flash drive. That way you have some sort of backup and everything under version control.

Good day, new user looking for some help.
I want to implement on my Pi. Where do I save the shell commands?
I assume I add the script to the HA script.yaml file?

And last I want to back up to my network drive.
Do I just replace your /mnt/… with 192.168.x.x/backup?

Thank you in advance

She’ll commands are a platform like many other integrations in HA. See above for how to add them to your Config file.

If your HA can see the drive it should be able to save there. You can test the commands before you add them to HA to make sure.

Thank you. Couple of questions:

I’ve inserted the shell command as instructed into the config.yaml file. However, my scripts are not in the config.yaml file; they’re in the supplementary scripts.yaml file. Does the script need anything extra to go to that file?

below find a sample; feedback appreciated.
shell_command:
backup_configuration: cp -a /home/hass/.homeassistant/configuration.yaml “/192.168.1.118/TimeMachine/Hassbian/configuration.yaml-$(date +”%m%d%Y-%H%M")"

Hass will work out where everything is stored on its own.

I am using Rsnapshot

I have configured it to make hourly, daily and weekly snapshots. It uses hard links so that if a file does not change, it will still be copied but it will not take extra space. I’ve excluded the database and some other files.

Another advantage is that each backup is a complete set of files, similar to Time Machine on a Mac.

thanks, can’t crack it.
my config file is in the following location:
smb://hassbian/homeassistant/configuration.yaml

your path is
/home/hass/.homeassistant/configuration.yaml

should i put smb instead of /home/?

thanks balk 77. followed the link which talks about a how to on the website, but cant see it?

Somebody made a tutorial for us:

  1. You specify what to backup
  2. And what name to use plus number of backups to retain
  3. Run the program via a cron job; I have a script named hourly scheduled to run every hour. Similar for the daily and weekly scripts

I’m getting /dev/sda1 file or directory not found.
When I try:
noauto,owner 0 0

in:
/etc/fstab

I get the same error.
USB sticks and sdcard adapters are write enable, formatted as per the guide in the link, etc.

You should mount your device first and then check what device it is on. For all we know it could be /dev/sdb1

If you don’t have some basics on linux mounting/partitioning/formating a device it might not be so easy for you. Double check with “dmesg” to see what device it is. Then check with fdisk /dev/ and “p” to print out the partitions to see if they are usable for your device.

Other then that, if your stuck… some screenshots & config files would be good to get me an idea what you are facing.

After disconnecting the usb drive and running dmesg, then reconnecting the drive after running dmesg again it appears that /dev/sda1 is mentioned.

After checking with fdisk I get the same no such file or directory as in my 1st post.

I tried:

lsblk (command not found)
sudo blkid (nothing happened, just new command prompt)
sudo fdisk -l (same result as blkid)

The usb drive was formatted as shown in below screenshot.

My configuration.yaml file is:



I’ve got suspicions that ExFat is not correct partition to use. I’m sure I either read somewhere to use that or my Mac wasn’t offering a correct option, so | resorted to choosing from one of the options my Mac made available :confounded:!

fdisk /dev/sda, /dev/sda1 points to a partition. If you don’t have that partition it will error.

Normally i just format them the same as my system, so for example ext3.
Check if you see something with /dev/sda

How do you do this in HASSIO?
How can you configure rclone in Docker?