supplierdeeply

Config Backup&Restore

  • 6 Replies
  • 1325 Views
Config Backup&Restore
« on: 09 / September / 2014, 17:46:56 »
Advertisements
Still having a lot of fun with CHDK thingies ... and bothering you with my mini scripts  :P
Just realized that i need an easy way to backup or restore my CHDK configuration.
So, after searching back and forth on the forum, i made my CHDK Config Backup&Restore lua mini script.
Theoretically it should run fine on all camera models with CHDK 1.3.
Obviously a restore requires a prior backup  ::)

Code: [Select]
--[[
@title CHDK Config Backup
 @param     b Action
  @default  b 1
  @values   b Restore Backup
--]]

require("drawings")
local core=require("gen/cnf_core")
local osd=require("gen/cnf_osd")
local user=require("gen/cnf_user")
local gps=require("gen/cnf_gps")
------------------------------------------------------------------
set_draw_title_line(0)                             -- title off
sleep(100)
if get_mode() == true then
    set_record(false)
    sleep(1000)
    while get_mode() do sleep(10) end
end
if (b==1) then                                      --- BACKUP
    save_config_file(core._config_id, "A/CHDK/_CORE_BKP.CFG")
    save_config_file(osd._config_id, "A/CHDK/_OSD_BKP.CFG")
    save_config_file(user._config_id, "A/CHDK/_USER_BKP.CFG")
    save_config_file(gps._config_id, "A/CHDK/_GPS_BKP.CFG")
    for i=0,30,1 do
     draw_string( 40, 150, ("   BACKUP DONE    "), 258, 263, 2, 2)
     sleep(100)
end
else                                                --- RESTORE
    load_config_file(core._config_id, "A/CHDK/_CORE_BKP.CFG")
    save_config_file(core._config_id)
    load_config_file(osd._config_id, "A/CHDK/_OSD_BKP.CFG")
    save_config_file(osd._config_id)
    load_config_file(user._config_id, "A/CHDK/_USER_BKP.CFG")
    save_config_file(user._config_id)
    load_config_file(gps._config_id, "A/CHDK/_GPS_BKP.CFG")
    save_config_file(gps._config_id)
    for i=0,30,1 do
     draw_string( 40, 150, ("   RESTORE DONE   "), 258, 263, 2, 2)
    sleep(100)
end
    draw.clear()
    play_sound(7)
    for i=0,20,1 do
     draw_string( 40, 150, ("   REBOOTING...   "), 258, 259, 2, 2)
    sleep(100)
end
end
if (b==0) then reboot() end
draw.clear()
set_record(true)
exit_alt()                                              -- done

Re: Config Backup&Restore
« Reply #1 on: 09 / September / 2014, 18:23:23 »
Nice.

A couple of other things that might be of interest :
http://chdk.setepontos.com/index.php?topic=9602.msg103557#msg103557
http://chdk.setepontos.com/index.php?topic=10126.msg101775#msg101775
http://trac.assembla.com/chdkde/browser/scripts/conf_rw/conf_rw.lua

"Different strokes for different folks".  Shamelessly steal anything there that appeals to you and ignore the rest.  Half the fun is writing a script is getting something that works exactly the way you want it to.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1237
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Config Backup&Restore
« Reply #2 on: 09 / September / 2014, 18:32:14 »
Have a look at this script: http://chdk.setepontos.com/index.php?topic=10894.msg106984#msg106984

Looks a little bit more modern.  :)

msl
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!

Re: Config Backup&Restore
« Reply #3 on: 09 / September / 2014, 20:21:21 »
OK, i got a bad mark ... and accused of robbery and to be out of date.
The above script was based on info got on the wiki and from the philmoz post. Maybe i should have had to report this last bibliographic note, but my script looks to me (in my naiveness) a good development of his hint, not a stealing of his code.
Please consider that i'm far away to be an expert in scripting, neither i want to compete against gurus.
So i apologize to all of you and promise to stop posting from now.


Re: Config Backup&Restore
« Reply #4 on: 09 / September / 2014, 20:36:06 »
OK, i got a bad mark ... and accused of robbery and to be out of date.
NO!  No no no no no no no .... and no.   That's the problem with these forums - stuff gets taken wrong and language translation barriers get things taken out of context / intent.

Quote
The above script was based on info got on the wiki and from the philmoz post. Maybe i should have had to report this last bibliographic note, but my script looks to me (in my naiveness) a good development of his hint, not a stealing of his code.
If you mean this :  "Shamelessly steal anything there that appeals to you and ignore the rest." - it's an English idiom that means you should take the best part of whatever scripts you can find and make something better.  It was supposed to be positive support and not intended to be negative or an accusation !!

Quote
Please consider that i'm far away to be an expert in scripting, neither i want to compete against gurus. So i apologize to all of you and promise to stop posting from now.
We will all be lesser if you choose to do so.
« Last Edit: 09 / September / 2014, 20:38:06 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Config Backup&Restore
« Reply #5 on: 09 / September / 2014, 20:56:21 »
Sorry for misunderstanding due to my bad english.

Ready for my next 100 scripts?  ... just kidding  :xmas

*

Offline msl

  • *****
  • 1237
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Config Backup&Restore
« Reply #6 on: 10 / September / 2014, 03:28:32 »
 
Anyone who can write his own scripts, is a winner.

msl
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!

 

Related Topics