Set up automatic backup Domoticz database

Set up automatic backup Domoticz database

28 May 2021 2 Door Bjorn Meijer

The importance of a backup

Making a backup is often underestimated. The value of a backup is only appreciated when the damage has already been done. Now I use Domoticz as a hobby and it is interesting to keep track of data, operate things remotely, etc.

For backing up data I use the 3-2-1 rule:

  • 3: Provide at least 3 copies of your data.
  • 2: Save the copies on at least two different media.
  • 1: Keep at least one copy outside your organization.

Should the data of Domoticz be lost for whatever reason, there is (for me) no man overboard and I start again. But prevention is better than cure, so I make sure that the Domoticz database is automatically stored in the cloud. For this I use duplication.

With Duplicati you can back up to different Cloud platforms such as Backblaze B2, Tardigrade, Microsoft OneDrive, Amazon S3, Google Drive, box.com, Mega, hubiC, etc. Duplicati is open source software and free!

Step 1: Install Mono Framework

Install it mono framework to use Duplicati.

sudo apt install mono-complete ca-certificates-mono -y

The entire framework is installed with this. Of ca-certificates-mono -y SSL certificates are installed to get HTTPS connections. If you experience problems with making HTTPS connections, it is advisable to install this as well.

Step 2: Sync the certificates

sudo cert-sync /etc/ssl/certs/ca-certificates.crt

Step 3: Install Duplicate

wget https://updates.duplicati.com/beta/duplicati_2.0.6.1-1_all.deb sudo apt-get install ./duplicati_2.0.6.1-1_all.deb -y

Step 4: Install missing program files

sudo apt -f install -y

Step 5: Create and edit the service file

sudo nano /etc/systemd/system/duplicati.service

The service file should look like this:

[Unit] Description=Duplicati web-server After=network.target [Service] Nice=19 IOSchedulingClass=idle EnvironmentFile=-/etc/default/duplicati ExecStart=/usr/bin/duplicati-server $DAEMON_OPTS Restart=always [Install] WantedBy =multiuser.target

Copy and paste the above code into the configuration file and save it.

Step 6: Configure the init script

sudo nano /etc/default/duplicate

# Defaults for duplicati initscript # sourced by /etc/init.d/duplicati # installed at /etc/default/duplicati by the maintainer scripts # # This is a POSIX shell fragment # # Additional options that are passed to the Daemon. DAEMON_OPTS="--webservice-interface=any --webservice-port=8200 --portable-mode"

Step 7: Start Duplicati service

To start the service we use the following commands.

sudo systemctl enable duplicati.service

sudo systemctl daemon-reload

sudo systemctl start duplicati.service

sudo systemctl status duplicati.service

Step 8: Open the Duplicati web interface

http:// :8200

After opening the Duplicati web interface you will see the message below. Choose “No, my machine has only a single account”.

Duplicati - First run setup
Duplicati – First run setup

Step 9: Add Backup

Click the “Add Backup” button in the menu and select “Set up a new backup”.

Duplicati - Add New Backup
Duplicati – Add New Backup

Step 10: General Backup Settings

Give the backup a clear name, description and possibly password. Be sure to keep the password in a safe place if you ever need to restore a backup. You can also choose not to enter a password.

Duplicati - General backup settings
Duplicati – General backup settings

Step 11: Select destination backup location

  • Select the storage type where you want to save the backup.
  • Specify the path on the server.
  • Enter username and/or password if necessary.
Duplicati - Set target location
Duplicati – Set target location

Step 12: Select source backup location

Select the folder /home/pi/domoticz/ as a source. Everything in the domoticz/ folder will be backed up.

Duplicati - Select source backup location
Duplicati – Select source backup location

Step 13: Schedule the automatic backup

Specify when the backup should be performed. I always back up twice a day. Once during the day and once at night.

Duplicati - Schedule Backup
Duplicati – Schedule backup

Step 14: Backup Options

Within the options you can specify the file size of the volumes. If you choose 50 MB and your backup is 144 MB, the backup will be split into two volumes of 50 MB and one volume of 44 MB.
Under “Backup retention” choose an option that suits you best. Also take into account the available space of the target location.

Duplicati - Backup options
Duplicati – Backup options

Step 15: Additional Options

It is possible to send e-mails via additional settings if a backup has been performed (incorrectly). on https://forum.duplicati.com/t/how-to-configure-automatic-email-notifications-via-gmail-for-every-backup-job/869 it explains step by step how to do this.