Backup HomeAssistant core configuartion to Dropbox

This script zips the home assistant configuration (.homeassistant directory, with exclusions defined in exclusions.txt file) and uploads it to dropbox. It even deletes backups older than specified, both from local storage and from dropbox.

:warning: This guide is aimed at users running Home Assistant Core in a Python Virtual Environment

I have combined two approaches for backing up configuration of HomeAssistant Core installation, hence most of the credit goes to the original authors.


Become homeassistant user

Become the homeassistant user (or whatever user runs Home Assistant). Change to whatever directory you would like the script to run

sudo -u homeassistant -H -s
mkdir -p ~/bin
cd ~/bin

Install dependencies


apt-get install zip

Dropbox-Uploder (see github project)

curl "" -o
chmod +x

Run ./ for the first time to set it up as per instructions on the first run.

Download and Run Script

Download the script and run with the following commands.

chmod +x backup-homeassistant

Edit the script file using your preferred text editor (eg nano). Change the paths to reflect your configuration, then simply run ./backup-homeassistant.

Exclusions text file sample (exclusions.txt) can be found here exclusions.txt

$ ./backup-homeassistant
[i] Creating backup
[i] Backup complete: /media/hassbackup/
[i] Deleting backups older then 10 day(s)
[i] Uploading to dropbox

Set up cron job

crontab -e

and place this on a single line to run cron job at 4 15 am every day. (more options →

15 4 * * * /home/homeassistant/bin/backup-homeassistant


  1. You can optionally encrypt the zip files (see man zip)


  1. This usb backup guide - thread id 196964 (sorry, i can post only two links)
  2. Dropbox-Uploader on github