This method save write cycles to the SD-card or SSD drive.
You should have rsync installed or change the rsync command to the cp command
You might have to do some small changes if you run Domoticz as a different user.
First create a tmpfs at boot of this path in /etc/fstab with
Code: Select all
tmpfs /home/pi/domoticz/scripts/dzVents/data tmpfs rw,size=1M 0 0Then create a backup directory with
Code: Select all
mkdir /home/pi/domoticz/scripts/dzVents/data_backupCode: Select all
sudo nano /lib/systemd/system/ramdisk-sync.serviceCode: Select all
[Unit]
Before=umount.target
[Service]
Type=oneshot
User=root
ExecStartPre=/bin/chown -Rf pi:pi /home/pi/domoticz/scripts/dzVents/data/
ExecStart=/usr/bin/rsync -ar /home/pi/domoticz/scripts/dzVents/data_backup/ /home/pi/domoticz/scripts/dzVents/data/
ExecStop=/usr/bin/rsync -ar /home/pi/domoticz/scripts/dzVents/data/ /home/pi/domoticz/scripts/dzVents/data_backup/
ExecStopPost=/bin/chown-Rf pi:pi /home/pi/domoticz/scripts/dzVents/data_backup
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Code: Select all
sudo systemctl daemon-reload
sudo systemctl enable ramdisk-sync.service
sudo systemctl start ramdisk-sync.service
sudo reboot