Moving Home Assistant DBs to external Flash Drives

imageSo timing is everything…  and my timing was perfect (ok, it was slow).  Chatting in the Discord forums with some way smarter *nix users than me (Tinkerer and Brian Cribbs), we were brainstorming some ideas on how to extend the life span of the Home Assistant raspberry Pis, we were running.  Specifically the SD Cards.  Since taking backups of the SD cards are kind of a pain in the ass, I had basically disabled recording and history on my Home Assistant configuration.   The solution we came up with was to move the really chatty log files and databases off the SD Card and onto a much more disposable thumb drive.  In my case, I have tons of them laying around but any good 16+ GB drive will do.  Perfect timing?  Of course! Both Brian and Tinkerer wrote up excellent tutorials that I just had to follow along with : Here & Here.

My Pi has 4 USB ports in the back of it, so I grabbed a 32 GB thumb drive and plugged it right in.  For the most part, I followed Tinkerer’s instructions.  Since I have been running an original install of Home Assistant, I did need to make a few changes (like substituting homeassistant with hass).  But in the end, the how to articles DELIVERED!  The high intensity DB and log files are now happily writing and rewriting to my disposable thumb drive.

Since I run the USPS component as well, I decided to move the cache index for that using sym links.

sudo ln -s /data/usps_cache.sqlite ~hass/.homeassistant/usps_cache.sqlite

Additionally, I also shared out this new drive in my Samba by adding the following configuration to my smb.conf.

[database]

path = /data

comment = No comment

browsable = yes

read only = no

valid users =

writable = yes

guest ok = yes

public = yes

create mask = 0777

directory mask = 0777

force user = root

force create mode = 0777

force directory mode = 0777

hosts allow =

Another easy thing for me to move was my Text to Speech cache directory.  This was a simple change to the cache_dir variable in my configuration.yaml

Thankfully, it all worked out and all is good!  Plus my thumb drive gives me a little red light every time Home Assistant writes to it.  Very comforting. Smile 

 <br />

TAGS