-class Backup
- class RegistryFile
- def initialize(registry, path)
- @registry = registry
- @path = path
- end
- def path
- @path
- end
- def abs
- File.expand_path(File.join(@registry, @path))
- end
- def ext
- File.extname(@path)
- end
- def valid?
- File.file?(abs) and %w{.db .tdb}.include? ext
- end
+# new formats:
+begin; require 'dbm'; rescue Exception; end
+begin; require 'daybreak'; rescue Exception; end
+
+puts 'RBot Registry Backup/Restore/Migrate'
+puts '[%s]' % ['Ruby: ' + RUBY_VERSION,
+ 'DBM: ' + (DBM::VERSION rescue '-'),
+ 'BDB: ' + (BDB::VERSION rescue '-'),
+ 'TokyoCabinet: ' + (TokyoCabinet::VERSION rescue '-'),
+ 'Daybreak: ' + (Daybreak::VERSION rescue '-'),
+ ].join(' | ')
+
+require 'date'
+require 'optparse'
+
+TYPES = [:bdb, :tc, :dbm, :daybreak, :auto]
+options = {
+ :profile => '~/.rbot',
+ :dbfile => './%s.rbot' % DateTime.now.strftime('export_%Y-%m-%d_%H%M%S'),
+ :type => :auto
+}
+opt_parser = OptionParser.new do |opt|
+ opt.banner = 'Usage: rbotdb COMMAND [OPTIONS]'
+ opt.separator ''
+ opt.separator 'Commands:'
+ opt.separator ' export: store rbot registry platform-independently in a file.'
+ opt.separator ' import: restore rbot registry from such a file.'
+ opt.separator ''
+ opt.separator 'Options:'
+
+ opt.on('-p', '--profile [PROFILE]', 'rbot profile directory. Defaults to: %s.' % options[:profile]) do |profile|
+ options[:profile] = profile
+ end
+
+ opt.on('-f', '--file [DBFILE]', 'cross-platform file to export to/import from. Defaults to: %s.' % options[:dbfile]) do |dbfile|
+ options[:dbfile] = dbfile