From 43c82e4e7b71137980cbc658c23e2f06cac629db Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 17 Jun 2011 15:19:39 +0200 Subject: [PATCH] Add backup option to onedb --- src/onedb/onedb | 10 +++++++++- src/onedb/onedb.rb | 8 +------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/onedb/onedb b/src/onedb/onedb index 5c5c0097d6..b1c257fdae 100755 --- a/src/onedb/onedb +++ b/src/onedb/onedb @@ -45,6 +45,14 @@ FORCE={ :description => "Forces the backup even if the DB exists" } +BACKUP={ + :name => "backup", + :short => "-b file", + :large => "--backup file", + :description => "Use this file to store SQL dump", + :format => String +} + ############################################################################### # SQLite options ############################################################################### @@ -203,7 +211,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do By default the DB is upgraded to the latest version EOT - command :upgrade , upgrade_desc, [:version, nil] do + command :upgrade , upgrade_desc, [:version, nil], :options=>[FORCE,BACKUP] do helper = OneDB.new(options) helper.upgrade(args[0], options) end diff --git a/src/onedb/onedb.rb b/src/onedb/onedb.rb index ec2d711925..98fd586148 100644 --- a/src/onedb/onedb.rb +++ b/src/onedb/onedb.rb @@ -109,13 +109,7 @@ class OneDB if File.exists?(file) && (max_version == nil || migrator_version <= max_version) # At least one upgrade will be executed, make DB backup - if ops[:backup] - bck_file = ops[:backup] - else - bck_file = @backend.bck_file - end - - @backend.backup(bck_file) + backup(ops[:backup], ops) end while File.exists?(file) &&