I finally have everything working as I wanted. This means Ubuntu, Docker, Openhab, access from windows and backup to synology. Thanks to the people who provided feedback on my questions.
If interested find below the steps I used
Install Ubuntu and the additional fixes (takes a few minutes before it popup)
- Install docker from App Center
- Running Docker as normal user
sud add group --system docker
sud adducer $USER docker
newsgroup docker
sudo snap disable docker
sudo snap enable docker
-
Install openhab by creating the required directories
mkdir -p /home/mynuc/docker/openhab4.1.1/addons
mkdir -p /home/mynuc/docker/openhab4.1.1/conf
mkdir -p /home/mynuc/docker/openhab4.1.1/userdata -
Give the folder and the sub-folders al rights
cd /home/mynuc/docker
sudo chmod -R a+rwx . -
Create yaml docker compose file
cd /home/mynuc/docker
nanu docker-compose.yml -
Add the following lines
services:
openhab:
image: "openhab/openhab:4.1.1"
restart: always
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "/home/mynuc/docker/openhab4.1.1/addons:/openhab/addons"
- "/home/mynuc/docker/openhab4.1.1/conf:/openhab/conf"
- "/home/mynuc/docker/openhab4.1.1/userdata:/openhab/userdata"
environment:
CRYPTO_POLICY: "unlimited"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Amsterdam"
OPENHAB_HTTP_PORT: "8080"
OPENHAB_HTTPS_PORT: "8443"
-
Run docker compose up -d
-
Check if you can access openhab with localhost and/or ip address on port 8080.
Share Openhab folders with Windows (I use VSC under windows)
-
Install samba
sudo apt install samba -
Configure samba what folder to share
sudo nano /etc/samba/smb.conf
The name between is the name popin-up in windows
[Docker_nuc]
path = /home/mynuc/docker
read only = No
guest ok = Yes
force user = mynuc
-
Restart the samba service
sudo service smbd restart -
Make it a network drive for windows
sudo apt install wsdd -
Check windows network
You should be able to select the docker folder without login -
I want to backup all the folders from Openhab in a tar file on Synology
*The steps on Synology are straight forward -
Map a shared folder from the Synology with the NUC
You should see NAS. Select the first option and login with your Synology credentials.
-
Now you should see the NAS
-
Install NFS
sudo apt-get install nfs-common -y -
Create a backup folder in the /srv folder. This seems to be important
sudo mkdir /srv/backup_nas -
Map both folders in a boot persistence way
sudo nano /etc/fstab
192.168.100.51:/volume1/backup_nuc /srv/backup_nas nfs defaults 0 0
-
Reload the deamon
systemctl -q daemon-reload -
Mount the folder
sudo mount -a -
Create a backup script what you can use with crown
Go to the docker folder
cd /home/mynuc/docker
Create the backup scripts file
nanu backup.sh
echo "Backing up openhab 4.1.1"
file=/srv/backup_nas/openhab-$(date +%Y-%m-%d_%H%M).tgz
cd /home/mynuc/docker/openhab4.1.1
tar cfz $file .
- Test the backup
sudo bash /home/mynuc/docker/backup.sh - Change the rights to run it as root
sudo chmod u+s backup.sh - Create a cron job for call the backup script file
sudo crontab e
35 16 * * * sudo bash /home/mynuc/docker/backup.sh
- Restart
sudo systemctl restart cron - Check if the jobs work after time is expired with
systemctl status cron