Easy backup on Raspberry Pi

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
gerpol
Posts: 9
Joined: Wednesday 03 June 2026 10:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Contact:

Easy backup on Raspberry Pi

Post by gerpol »

The Domoticz wiki gives some examples how to backup the domoticz database to a remote server here: https://wiki.domoticz.com/Daily_backup_to_external_hdd
Unfortunately these examples have some security flaws.

I did it differently in a simple and safe way, using the standard backup option and scp over SSH for which no plain password needs to be saved in a script file.

The procedure is:

on the domoticz local machine:

Code: Select all

cd .ssh/
ssh-keygen -t rsa
scp id_rsa.pub pi@remoteserver:/home/pi/.ssh

On the remoteserver:

Code: Select all

cd .ssh
mv id_rsa.pub authorized_keys
chmod 700 authorized_keys
mkdir /home/pi/domoticz                   $ adapt to your needs
mkdir /home/pi/domoticz/backups
mkdir /home/pi/domoticz/backups/daily

on the domoticz local machine:

Code: Select all

#!/bin/bash
SERVER="remoteserver.local"                    # IP or name of server
USER="pi"
REMOTEPATH="/home/pi/domoticz/backups/daily/"     # adapt to your needs
LOCALPATH="/home/pi/domoticz/backups/daily/"
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%d`
BACKUPFILE="backup-day-$TIMESTAMP-Domoticz.db" #  name of daily backup file
scp -r $LOCALPATH/$BACKUPFILE $USER@$SERVER:$REMOTEPATH      
And then put this in cron.

More details on my website:
https://www.agri-vision.nl/portal/artic ... z-database
Post Reply