Restoring from full backup - db gone

Hello,

I migrated my Home Assistant setup from an intel nuc to a raspberry pi 4 by doing complete backup and restore. Everything seems to be fine except for the MariaDB addon which has some trouble starting up.

Before I backed up the old system I made sure that I am using the latest version of both Home Assistant and Home Assistant OS. Both systems run core-2021.9.6, supervisor-2021.09.0 and OS 6.4.

Here are the logs from the addons and the startup logs of the system:

MariaDB addon logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[17:27:27] INFO: Using existing mariadb initial system
[17:27:27] INFO: Starting MariaDB
210915 17:27:28 mysqld_safe Logging to '/data/databases/mariadb.err'.
210915 17:27:28 mysqld_safe Starting mysqld daemon with databases from /data/databases
210915 17:27:28 mysqld_safe Starting mysqld daemon with databases from /data/databases
2021-09-15 17:27:28 0 [Note] /usr/bin/mysqld (mysqld 10.4.19-MariaDB) starting as process 396 ...
2021-09-15 17:27:28 0 [Note] InnoDB: Using Linux native AIO
2021-09-15 17:27:28 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-09-15 17:27:28 0 [Note] InnoDB: Uses event mutexes
2021-09-15 17:27:28 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-09-15 17:27:28 0 [Note] InnoDB: Number of pools: 1
2021-09-15 17:27:28 0 [Note] InnoDB: Using generic crc32 instructions
2021-09-15 17:27:28 0 [Note] mysqld: O_TMPFILE is not supported on /var/tmp (disabling future attempts)
2021-09-15 17:27:28 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-09-15 17:27:28 0 [Note] InnoDB: Completed initialization of buffer pool
2021-09-15 17:27:28 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-09-15 17:27:28 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=110694875075
2021-09-15 17:27:28 0 [Note] InnoDB: Starting final batch to recover 49 pages from redo log.
210915 17:27:29 mysqld_safe mysqld from pid file /data/databases/core-mariadb.pid ended

phpMyAdmin addon logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: phpMyAdmin
 A web interface for the official MariaDB add-on
-----------------------------------------------------------
 Add-on version: 0.5.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.4  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2021.9.6
 Home Assistant Supervisor: 2021.09.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] phpmyadmin.sh: executing... 
[17:34:52] ERROR: Got unexpected response from the API: Service not enabled
[cont-init.d] phpmyadmin.sh: exited 139.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Home Assistant start-up logs:

2021-09-15 17:36:39 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup to mysql://homeassistant:homeassistant@core-mariadb/homeassistant?charset=utf8: (MySQLdb._exceptions.OperationalError) (2002, "Can't connect to MySQL server on 'core-mariadb' (115)")
(Background on this error at: https://sqlalche.me/e/14/e3q8) (retrying in 3 seconds)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3212, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 307, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 767, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 425, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 253, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 368, in __init__
self.__connect()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 611, in __connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 605, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 578, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 584, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2002, "Can't connect to MySQL server on 'core-mariadb' (115)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 680, in _setup_recorder
self._setup_connection()
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 964, in _setup_connection
Base.metadata.create_all(self.engine)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4740, in create_all
bind._run_ddl_visitor(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3078, in _run_ddl_visitor
with self.begin() as conn:
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2994, in begin
conn = self.connect(close_with_result=close_with_result)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3166, in connect
return self._connection_cls(self, close_with_result=close_with_result)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
else engine.raw_connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3245, in raw_connection
return self._wrap_pool_connect(self.pool.connect, _connection)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3215, in _wrap_pool_connect
Connection._handle_dbapi_exception_noconnection(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2069, in _handle_dbapi_exception_noconnection
util.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3212, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 307, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 767, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 425, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 253, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 368, in __init__
self.__connect()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 611, in __connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 605, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 578, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 584, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2002, "Can't connect to MySQL server on 'core-mariadb' (115)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)
2021-09-15 17:36:42 ERROR (MainThread) [homeassistant.setup] Setup failed for recorder: Integration failed to initialize.
2021-09-15 17:36:44 WARNING (MainThread) [homeassistant.components.speedtestdotnet] The 'speedtestdotnet' option near /config/configuration.yaml:1 is deprecated, please remove it from your configuration
2021-09-15 17:36:47 ERROR (MainThread) [homeassistant.setup] Setup failed for alexa_media: Integration not found.
2021-09-15 17:36:47 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of logbook. Setup failed for dependencies: recorder
2021-09-15 17:36:47 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: Could not set up all dependencies.
2021-09-15 17:36:47 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of history. Setup failed for dependencies: recorder
2021-09-15 17:36:47 ERROR (MainThread) [homeassistant.setup] Setup failed for history: Could not set up all dependencies.
2021-09-15 17:36:48 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of energy. Setup failed for dependencies: history, recorder
2021-09-15 17:36:48 ERROR (MainThread) [homeassistant.setup] Setup failed for energy: Could not set up all dependencies.
2021-09-15 17:36:49 ERROR (MainThread) [homeassistant.components.automation] Platform automation does not generate unique IDs. ID garage_door_open_close already exists - ignoring automation.notification_for_the_garage_door
2021-09-15 17:36:53 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: energy, history, logbook
2021-09-15 17:36:53 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: Could not set up all dependencies.

I guess you did not stop the mariadb before the backup ?

Nope, since home assistant is made for idiots now, I just thought that everything that should be done for a proper backup will be done automatically. On top of that, I think this is the 3rd time I migrate my system to another computer using this technique and I didn’t have any problems so far… For example, when I migrated to the NUC I currently use, I did exactly the same as now…

1 Like

This also happened to me with the original db HA.
Q: Is it possible to stop automating mariadb before backing up for example Samba Backup?

it is with google drive backup, don’t know about samba backup.

I use this add-on, which works reliably.
I save backups to a local disk on my LAN.

I have experienced a similar problem when I restored a backup three days old. My history for these three days was gone.

I am using mariadb core. Question is, would I preserve the history if I write to my local database on my home NAS? I would say so. HA should not have any relation to it if it intentionally not deletes it. MariaDB core is, I guess, partnof the “core” which is restoring. These db drops could be a problem when I decide to fully use the energy component in HA.