{"id":90,"date":"2023-03-30T08:24:56","date_gmt":"2023-03-30T07:24:56","guid":{"rendered":"http:\/\/192.168.1.114\/wordpress\/?p=90"},"modified":"2023-11-06T21:08:30","modified_gmt":"2023-11-06T20:08:30","slug":"moving-homeassistant-config-from-docker","status":"publish","type":"post","link":"https:\/\/daniel.schoenmaker.xyz\/?p=90","title":{"rendered":"Moving HomeAssistant config from docker"},"content":{"rendered":"\n<p class=\"has-drop-cap\">Let me start with a confession. Many months ago I was too impatient to start with HA and I have been lacking my security responsibilities since. Time for change and since I couldn&#8217;t find a comprehensive guide, let me write another incomprehensive guide. But hopefully it will be the piece of the puzzle you&#8217;re missing.<\/p>\n\n\n\n<p>So what went wrong? I installed HA docker image without a separate location for the config and couldn&#8217;t update the image because of it. Last week I took the plunge and went to fix this issue. What had to happen?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating a backup for my current docker image \/ HA instance<\/li>\n\n\n\n<li>Creating a new HA instance with the config file on a location outside of the docker image<\/li>\n\n\n\n<li>Moving the current configuration to the new docker image<\/li>\n<\/ul>\n\n\n\n<p><strong>Prerequesites<\/strong><\/p>\n\n\n\n<p>If, like me, this action also includes an upgrade, check the release notes for breaking changes and please update and\/or upgrade your system before moving the configuration. In my case, my z-wave integration broke for example and HA couldn&#8217;t run because of an outdated libseccomp2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a backup for my current HA instance<\/h2>\n\n\n\n<p>To be able to use the &#8216;normal&#8217; docker commands provided by HA, I wanted to rename the current docker installation so it wouldn&#8217;t get overwritten and still be able to function while configuring the rest. I did this with the command <code>docker rename homeassistant oldhomeassistant <\/code>after first running <code>docker stop homeassistant<\/code>. This renames the homeassistant docker container to &#8216;oldhomeassistant&#8217;, which is helpfull because you can now install a new container while still running the old one. Be aware that you can only access one at a time, so you&#8217;d have to stop the old one to test the new one. <code>docker start oldhomeassistant<\/code> to be sure the container &#8216;oldhomeassistant&#8217; still works as expected before you install the new container.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create new HA container with persistent config file<\/h2>\n\n\n\n<p>This part you mostly know from https:\/\/www.home-assistant.io\/installation\/raspberrypi. I created a folder for persistent storage of the configuration files under the \/etc dir with <code>sudo mkdir \/etc\/homeassistant\/config\/ <\/code>and pointed the docker run command to it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name homeassistant \\\n  --privileged \\\n  --restart=unless-stopped \\\n  -e TZ=Europe\/Amsterdam \\\n  -v \/etc\/homeassistant\/config:\/config \\\n  --network=host \\\n  --device=\/dev\/serial\/by-id\/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0:\/dev\/rflink \\\n  ghcr.io\/home-assistant\/home-assistant:stable<\/code><\/pre>\n\n\n\n<p>Check if the configuration.yaml and other files appeared under \/etc\/homeassistant\/config. If true then <code>docker stop homeassistant<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copying config from docker to pi<\/h2>\n\n\n\n<p>This is the important part. Make sure all containers are stopped with <code>docker ps -a | grep homeassistant<\/code>  which should return two &#8216;exited&#8217; containers.<br>Then run <code>sudo docker cp homeassistantold:\/config \/etc\/homeassistant\/<\/code> to copy all files from the old docker container to the location from which the new docker container gets its configuration files. If this is done you should be able to <code>docker start homeassistant <\/code>and opening your homeassistant in the browser you should see some familiar information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let me start with a confession. Many months ago I was too impatient to start with HA and I have been lacking my security responsibilities since. Time for change and since I couldn&#8217;t find a comprehensive guide, let me write another incomprehensive guide. But hopefully it will be the piece of the puzzle you&#8217;re missing. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wordproof_timestamp":false},"categories":[9,10,11,13,7],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-domotica","category-homeassistant","category-raspberry-pi","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":1,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions\/134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=\/wp\/v2\/media\/133"}],"wp:attachment":[{"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.schoenmaker.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}