Page 1 of 1

add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 10:02
by eriksson25
Hi, Love Domoticz and I am working on a big system for a campsite. Gone controll >50 rooms and lots of other things.

But I want everything to be backedup if for example a thunderstorm wipes out my rpi/sdcard.

I have domoticz doing database backups, and then I have a tar script making a backup of my entire /home/pi folder for smooth restoration. The rpi also uploads the backups to dropbox for safe keeping.

But I have one problem. I would like to add the domoticz version number into the filename of the backupfile. To easy be able to identify and download the correct version if restoration is needed.

I found that in the History.txt in domoticz folder the first line states the current version like this.

Version 3.4834 (March 2nd 2016)

So I have been trying to take this and add it into the filename but without sucess. So I was thinking maby someone have a solution?

Re: add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 10:45
by Egregius
Why not just use a date/time stamp in your filename?
I think it's easier to know to what date you want to revert than to what version.

Re: add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 10:56
by eriksson25
Hi, I allredy do that ofc. And for just reverting to a stable version when somethings is not working that is enough.

But if the lightning takes out all hardware I will need to know what version was used (might not have been updated in a year or more), so that I can get the same version image with the same debian karnell versions and so forth. To make sure that the backup is 100% compatible.

Re: add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 13:28
by eriksson25
Awsome! Thanks. Just what I needed!

Working great

Re: add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 13:36
by Eduard
You can get the current version of the running Domoticz via:

Code: Select all

http://<ip>:<port>/json.htm?type=command&param=getversion
In bash, you can store this versionnumber in a variable via curl:

Code: Select all

#Retrieve current Domoticz versionnumber
json=`curl -s -X GET "http://<ip>:<port>/json.htm?type=command&param=getversion"`
version=$(echo $json |grep -Po '(?<="version" : ")[^"]*')

Re: add Domoticz version number to textfile name

Posted: Thursday 07 April 2016 17:37
by Pjedr
Another solution I use in my upgrade script:

Code: Select all

TIMESTAMP=`/bin/date +%Y-%m-%d-%H%M`
VERSION=`cat /mnt/GrabnGo_2TB/peter/domoticz/appversion.h.txt | grep "#define APPVERSION " | cut -c20-`
BACKUPFILE="/mnt/GrabnGo_2TB/peter/Domoticz_${TIMESTAMP}_${VERSION}.tar.gz"
echo "Makket Backup fan /mnt/GrabnGo_2TB/peter/domoticz nei $BACKUPFILE" 
tar cPzf $BACKUPFILE /mnt/GrabnGo_2TB/peter/domoticz; #tar xpvzf "Domoticz_$TIMESTAMP.tar.gz"