Backup your Backups

Hi

I have CIFS enabled on my Vera and my NAS mapped to it.

I was wondering if anyone was backing up their backups , and if so if they could share the lua code they are using to do it.

Also are there any other files on Vera that should be backed up too?

I just posted an answer about this at:

http://forum.micasaverde.com/index.php/topic,23950.msg164045.html#msg164045

Thanks @RTS

Now I know the request to create a new back up file → http://your.local.vera.ip.address/cgi-bin/cmh/backup.sh

I’ve reworked the following code based on bits I’ve found online

local backup = io.open("/cgi-bin/cmh/backup.sh", "r") local output_filename = "/nas/vera_backup_" .. os.date("%Y%m%d-%H%M%S") ..".sh" local output = io.open(output_filename, "w") output:write(backup:read("*all")) output:close() backup:close()

I’ve not tested it yet, as I read this Programming in Lua : 21.2 and wanted to ask if I should use (b) rather than (r) if .sh is a binary file?

Hi

When running the above code, I receive the following error.

Please could someone help me troubleshoot it…

01 08/18/14 8:52:44.704 LuaInterface::StartEngine failed run: 0 [string “local backup = io.open(”/cgi-bin/cmh/backup…“]:4: attempt to index local ‘backup’ (a nil value) <0x2fbc4680>
01 08/18/14 8:52:44.704 JobHandler_LuaUPnP::RunLua failed: local backup = io.open(”/cgi-bin/cmh/backup.sh", “r”)

FYI…

I can see the backup.sh file in /cgi-bin/cmd/ so not sure why it failed?
I think it’s telling me line 4: failed which is the write part…
Does it think the backup.sh is empty or maybe it can’t create the destination file on the NAS ?

Please could someone help me troubleshoot it..

I thought I already did - back in March.

[url=http://forum.micasaverde.com/index.php/topic,23832.msg164570.html#msg164570]http://forum.micasaverde.com/index.php/topic,23832.msg164570.html#msg164570[/url]

@Rex

Wow! - Your memory is way better than mine ! Have you got yourself a cape yet ? :slight_smile:
Thanks you so much for jogging mine.

I’ve had to rebuild a new Vera so I lost a number of things and I’m now trying to put all the pieces back

[code]luup.call_timer(“dailybackup”, 2 , “00:09:00” ,“1,2,3,4,5,6,7”, “”)

function clrTaskMsg(handle)
luup.task(“”,4,“”,tonumber(handle))
end

function dailybackup ()
local handle = luup.task(“Loading…”,1,“AutoBackup”,-1)
local error, result = luup.inet.wget(“http://192.168.1.234/cgi-bin/cmh/backup.sh” ,30)
if error ~= 0 then
luup.task(“Error loading backup!”,1,“AutoBackup”,handle)
luup.call_delay(“clrTaskMsg”,10,handle)
return false
end
local outfile = “/nas/vera_backup_” … os.date(“%Y%m%d-%H%M%S”)
local f,err = io.open(outfile,“w”)
if not f then
luup.task(err,1,“AutoBackup”,handle)
luup.call_delay(“clrTaskMsg”,10,handle)
return false
end
luup.task(“Writing file…”,1,“AutoBackup”,handle)
f:write(result)
f:close()
luup.task(“Finished.”,1,“AutoBackup”,handle)
luup.call_delay(“clrTaskMsg”,10,handle)
return true
end
[/code]

Look correct to you?

Look correct to you?

That should work. As it is being run automatically, you may want to change the way it reports progress. There isn’t too much point in showing Task messages if you are not there to see them. On the other hand, you probably want to know if there was an error.

If you use SysLog, you could write the messages there. If not, then you could use luup.log(…) statements. You may want to retain the Task message for a failure but don’t clear it. That way you would be alerted to a problem.

Thanks again Rex

I will look into changing the task messages to Prowl notification code, that way I will be told the result via a push notification to my phone - and it’ll be stored within the Prowl app too to refer back to.

Re SysLogging - do you have any advice on a syslog set up ? I’ve seen it mentioned a few times on the forum, but not sure of the the product / set up people should use with Vera?

Any recommendations ?

I log to my Synology NAS. It has a reasonable interface for viewing logs and automatic archiving.

I have EventWatcher log all watched variables to SysLog - just by setting the variable Syslog to :514 - a fine piece of work by @akbooer.

You can send Syslog events from scenes using - Writing to Syslog by @akbooer

Is anyone aware of a command to issue that would cause the ZWave network to be backed up as well as the system?

EDIT: Found it and wrote a shell script to backup Zwave and system on an a schedule. Details here: [url=http://forum.micasaverde.com/index.php/topic,30188.msg214990.html#msg214990]http://forum.micasaverde.com/index.php/topic,30188.msg214990.html#msg214990[/url]

Gerry