summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/byteback-receive15
-rwxr-xr-xbin/byteback-restore15
-rw-r--r--lib/byteback/restore.rb14
3 files changed, 23 insertions, 21 deletions
diff --git a/bin/byteback-receive b/bin/byteback-receive
index f475446..87d3071 100755
--- a/bin/byteback-receive
+++ b/bin/byteback-receive
@@ -25,24 +25,27 @@ fatal("#{byteback_root} does not exist") unless File.directory?(byteback_root)
#
# Force restores to be limited to the hostname we're connecting form
#
+
+
+
if (ARGV[0] == 'byteback-restore')
args = ["rsync"]
- revision = nil
+ snapshot = nil
while((arg = ARGV.shift) != ".")
break if arg.nil?
verbose = arg if arg == "--verbose"
- if arg == "--revision"
- revision = ARGV.shift
+ if arg == "--snapshot"
+ snapshot = ARGV.shift
else
args << arg
end
end
restore = Byteback::Restore.new(byteback_root)
- restore.revision = revision if revision
+ restore.snapshot = snapshot if snapshot
restore.find(Byteback::Restore.decode_args(ARGV))
Dir.chdir(byteback_host)
@@ -73,7 +76,7 @@ opts = Trollop.options do
opt :ping, 'Check connection parameters and exit'
opt :list, 'Show backed up files matching the given pattern'
opt :list_all, 'Show all stored versions of a file'
- opt :revision, 'Show backed up files in a certain revision.', :default => '*'
+ opt :snapshot, 'Show backed up files in a certain snapshot.', :default => '*'
opt :restore, 'Perform a restoration operation', :type => :string
opt :complete, 'Mark current backup as complete'
end
@@ -85,7 +88,7 @@ elsif opts[:list]
args = Byteback::Restore.decode_args(ARGV[1..-1])
restore = Byteback::Restore.new(byteback_root)
- restore.revision = opts[:revision]
+ restore.snapshot = opts[:snapshot]
restore.find(args, :all => opts[:list_all], :verbose => opts[:verbose])
if restore.results.empty?
diff --git a/bin/byteback-restore b/bin/byteback-restore
index 0a068a8..6afb1c2 100755
--- a/bin/byteback-restore
+++ b/bin/byteback-restore
@@ -35,8 +35,8 @@ def ssh(*ssh_args)
system(*args)
end
-def list_files(revision, list_all, pattern)
- args = ['byteback-receive', '--revision', revision, '--list']
+def list_files(snapshot, list_all, pattern)
+ args = ['byteback-receive', '--snapshot', snapshot, '--list']
args << "--list-all" if list_all
args << @verbose if @verbose
args += Byteback::Restore.encode_args(pattern)
@@ -51,8 +51,7 @@ end
# do that by setting "rsync-path" to point to a faux script.
#
#
-def restore_files(paths, revision)
-
+def restore_files(paths, snapshot)
#
# Basic args
#
@@ -64,7 +63,7 @@ def restore_files(paths, revision)
args += ['--timeout', @io_timeout.to_s ] unless ( @io_timeout.nil? )
args += ['--rsh', "ssh -o BatchMode=yes -x -a -i #{@ssh_key} -l #{@destination_user}"]
args << '--verbose' if @verbose
- args += ['--rsync-path', "byteback-restore --fake-super --revision #{revision}"]
+ args += ['--rsync-path', "byteback-restore --fake-super --snapshot #{snapshot}"]
dst = "#{@destination_user}@#{@destination_host}:"
paths.each do |path|
@@ -93,7 +92,7 @@ if __FILE__ == $PROGRAM_NAME
opt :restore, "Restore the files"
- opt :revision, "The version of the file to restore.",
+ opt :snapshot, "The snaphot to use.",
:type => :string, :default => "*"
opt :destination, 'Backup destination (i.e. user@host:/path).',
@@ -164,10 +163,10 @@ if __FILE__ == $PROGRAM_NAME
#
# Restore a file
#
- restore_files(ARGV.collect{|a| File.expand_path(a)}, opts[:revision])
+ restore_files(ARGV.collect{|a| File.expand_path(a)}, opts[:snapshot])
exit(0)
end
- list_files(opts[:revision], opts[:list_all], ARGV.collect{|a| File.expand_path(a)})
+ list_files(opts[:snapshot], opts[:list_all], ARGV.collect{|a| File.expand_path(a)})
exit(0)
end
diff --git a/lib/byteback/restore.rb b/lib/byteback/restore.rb
index e2df3fe..82fab82 100644
--- a/lib/byteback/restore.rb
+++ b/lib/byteback/restore.rb
@@ -5,9 +5,9 @@ module Byteback
class Restore
- def self.find(byteback_root, revision, paths)
+ def self.find(byteback_root, snapshot, paths)
x = Byteback::Restore.new(byteback_root)
- x.revision = revision
+ x.snapshot = snapshot
x.find(paths)
return x
end
@@ -39,15 +39,15 @@ module Byteback
#
@byteback_root = File.expand_path(byteback_root)
@now = Time.now
- @revision = "*"
+ @snapshot = "*"
@results = []
end
- def revision=(r)
+ def snapshot=(r)
if r =~ /^[a-z0-9:\+\*\-]+$/i
- @revision = r
+ @snapshot = r
else
- puts "*** Warning: Bad revision #{r.inspect}"
+ puts "*** Warning: Bad snapshot #{r.inspect}"
end
end
@@ -64,7 +64,7 @@ module Byteback
seen = []
@results = paths.collect do |path|
- Dir.glob(File.expand_path(File.join(@byteback_root, @revision, path))).collect do |f|
+ Dir.glob(File.expand_path(File.join(@byteback_root, @snapshot, path))).collect do |f|
restore_file = Byteback::RestoreFile.new(f, @byteback_root, @now)
end
end.flatten.sort{|a,b| [a.path, a.snapshot_time] <=> [b.path, b.snapshot_time]}