Skip to main content
  1. My Blog posts/

Move huginn dockerized instance to Raspberry Pi 4

·567 words·3 mins·
tech mastodon huginn docker mariadb raspi floss
Víctor (Bit-Man) Rodríguez
Author
Víctor (Bit-Man) Rodríguez
Algorithm Junkie, Data Structures lover, Open Source enthusiast

Update 19-Jan-2024: change URLs to reflect new repository location

Once you stick to open source there is no way back, you will learn tech stuff and also how to communicate with others to obtain information to perform your duties and to communicate you findings to give back to the community

Having installed Huginn into my laptop (source) to test it, and with some basic stuff running, I decided to move it to it’s final (target) destinantion: the Raspberry Pi 4 production environment. No way to start it from scratch and don’t want to let those hours get lost then I decided for a more fruitfull approach : 1) Huginn database backup (MariaDB flavor), 2) setup Raspi docker environment and 3) peform the database restore. Having a fully scripted environment setup using Docker this should be easy as pie. Easier said than done

2- Setup Raspi docker environment #

There’s no typo, just started with step two because is the less disruptive and will let’s execute and comprehend steps 1 and 3 at full extent

Let me say that there is no oficial Huginn docker image for linux/arm64 instead I found one created by Dedy Martadinata S. It was simple as replacing the oficial image with the found one and all started running. MariaDB is a multiplatform image already

1- Huggin database backup (MariaDB flavor) #

Usually performing a mysqldump (backup) at the source and mysql (restore) at the target is enough but still left us with the issue of accessing to the databse inside docker image to execute these commands and the data extraction (.sql file) from source database and it’s loading into destinarion database

The chosen mechanism for extraction, copy and loading into docker image was ssh. Here are the steps :

  • Export ssh port 22 to be able to access it from your host machine. I’ve chosen port 3322
  • (Re)start MariaDB container
# docker start huggin_mariadb_1
  • Access running MariaDB container through shell and set root password
# docker exec -it huggin_mariadb_1 bash
# passwd
New password: ********
Retype new password: ********
passwd: password updated successfully
  • Install ssh server (Debian Linux derivative)
# apt-get update
# apt-get install openssh-server
  • To be able to access the container through ssh using root user set PermitRootLogin to yes in config file /etc/ssh/sshd_config
  • Start ssh server
# /etc/init.d/ssh start
* Starting OpenBSD Secure Shell server sshd               [ OK ]
  • From your host machine ssh into your MariaDB container using previously set root password to ensure .sql file can be copied.
$ ssh -v -p 3322 root@localhost
root's password: ********
  • Now proceed to backup the Huginn database from inside MariaDB instance
# mysqldump --user=root --password huginn > huginn.sql
Enter password: ********
  • And finally copy the .sql file to the host machine
$ scp -P 3322 root@localhost:/root/huginn.sql $HOME

3- peform the database restore #

I will not repeat myself here but have to do the same magic performed at step 1 to install ssh into the targe MariaDB machine then :

  • Copy the .sql file to your target host machine (raspi4 in my case)
  • Copy the .sql file to the target MariaDB container
$ scp -P 3322 $HOME/huginn.sql root@localhost:/root
  • Perform the restore operation
# mysql --user root --database=huginn --password < /root/huginn.sql
Enter password: ********

Once finishe (re)start your huginn instance and it should contain the same agents, scenario, events, users and everything else that your source Huggin setup has

Hope you enjoyed!