add Domoticz version number to textfile name

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
eriksson25
Posts: 10
Joined: Sunday 25 January 2015 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

add Domoticz version number to textfile name

Post 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?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: add Domoticz version number to textfile name

Post 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.
eriksson25
Posts: 10
Joined: Sunday 25 January 2015 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: add Domoticz version number to textfile name

Post 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.
eriksson25
Posts: 10
Joined: Sunday 25 January 2015 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: add Domoticz version number to textfile name

Post by eriksson25 »

Awsome! Thanks. Just what I needed!

Working great
Eduard
Posts: 139
Joined: Monday 19 January 2015 9:14
Target OS: -
Domoticz version:

Re: add Domoticz version number to textfile name

Post 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" : ")[^"]*')
Pjedr
Posts: 38
Joined: Friday 27 December 2013 3:13
Target OS: Linux
Domoticz version: Beta
Location: Friesland
Contact:

Re: add Domoticz version number to textfile name

Post 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"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest