Set up automatic backup Domoticz database
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_126.96.36.199-1_all.deb sudo apt-get install ./duplicati_188.8.131.52-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=multi-user.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
After opening the Duplicati web interface you will see the message below. Choose “No, my machine has only a single account”.
Step 9: Add Backup
Click the “Add Backup” button in the menu and select “Set up a 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.
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.
Step 12: Select source backup location
Select the folder
/home/pi/domoticz/ as a source. Everything in the domoticz/ folder will be backed up.
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.
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.
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.