#!/usr/bin/env ruby

require 'backup_restore'
require 'windows/authorization'

class Restore
  extend BackupRestore

  def self.usage
    warn <<-EOT
Usage: restore <target> [<source>]

By default, restore from RedmineLE/backup directory.

Targets:
  all
  #{targets.join("\n  ")}
    EOT
  end
end

if ARGV.length < 1
  Restore.usage
  exit
end

Windows::Authorization.runas_admin

print <<EOT
=== Warning ===
Current data will be overwritten by backup data.
The service will be stopped and restarted automatically.

=== Confirmation ===
EOT
print "Are you sure you want to continue? (y/[n]): "

exit if STDIN.gets[0,1].downcase != "y"

Restore.restore ARGV
