I'm running Domoticz on my Synology NAS and as Dashticz is not an official part of Domoticz, Dashticz gets lost after Domoticz updates including the customisations that were made. So I looked into automatically backing up the Dashticz data, turns out it is quite simple and does not really require complicated coding. I'm not an expert, but I'm posting this to share with others and to maybe we can jointly improve it.
Synology has a Task Scheduler incorporated in the control panel, this can be used to run custom script files (although that doesn't seem to work properly for me due to root permission issues). But it can also be used to directly execute a line of code without having a separate script file. See below how to make this happen for daily backing up the "custom" folder of Dashticz:
- 1. Go to Control Panel > Task Scheduler and click on Create > Scheduled task > User-defined script.
- 2. In the window that opens, give your task a name (on my system the user is default set on "root" and "enabled" is ticked). And then click on "Schedule".
- 3. At the "Schedule" tab, choose the settings that you like. In the example below it backs up every day at 04:00. Then click on the "Task settings" tab.
- 4. At the "Task settings" tab, paste the following code in the "user-defined script" box.
For example, in my case, I'm using:
Code: Select all
sudo tar -cpzf /backup/destination/path/Dashticz_backup_`date +%Y-%m-%d`.tar.gz /source/path/domoticz/www/dashticz_v2/custom
This code creates a compressed file with filename "Dashticz_backup_2017-09-14.tar.gz" (date is automatically changed) with the contents of the "custom" folder of Dashticz, it then places it in my destination folder which in my case is a folder I sync with dropbox to have an offsite backup of the files, but you can place it in any folder really. Please note that the source path is not the same for everybody as Domoticz is installed in the folder of a user on your NAS, so check where Domoticz is installed on your NAS.Code: Select all
sudo tar -cpzf /volume1/Dropbox/AutoBackups/Dashticz/Dashticz_backup_`date +%Y-%m-%d`.tar.gz /usr/local/domoticz/www/dashticz_v2/custom
- 5. Click "OK" to save your task.
- 6. You can test your script in the Task Scheduler by right clicking on it and choose "run". It will ask for confirmation, click "yes".
If the script doesn't work it is most likely because there is a mistake in the folder naming (mind the capitals) or the folder you want to place the backup in doesn't exist yet.
The questions i still have are;
- Is there any other data that I would need to back-up? I can imagine the "img" folder for custom background images etc. Initially i backed up the whole Dashticz folder, but that quickly adds up in MBs if you daily back it up. Differential backups would be better in that case, but I don't know how to make that happen in a simple way. Plus what happens if the Dashticz folder is empty of non existent, will the backup just fail or will it replace the date with an empty folder?
- It would be nice to have a similar setup for restoring the data (e.g. after a Domoticz update) because the Tasks on the Synology can be easily manually activated. Maybe this could be something like
Code: Select all
cp -a /backup/source/path/. /domoticz/www/
Gr. Ingmar