diff options
author | Steve Kemp <steve@steve.org.uk> | 2015-06-03 15:55:28 +0100 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2015-06-03 15:55:28 +0100 |
commit | a29380762b93737ae6949121010cd9bceb8196b2 (patch) | |
tree | 4dfe2931401d0cc73c38b9a90377e31210d6706e /byteback-receive | |
parent | c4da983bd2a1e35450dcb21bdc7110f5fc0d166a (diff) |
Relocated the binaries to bin/
Diffstat (limited to 'byteback-receive')
-rwxr-xr-x | byteback-receive | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/byteback-receive b/byteback-receive deleted file mode 100755 index 4b949c2..0000000 --- a/byteback-receive +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/ruby -# -# Program to receive backups and run rsync in receive mode. Must check that -# user as authorised by SSH is allowed to access particular directory. - -$LOAD_PATH << '/usr/lib/byteback' - -require 'trollop' -require 'byteback' -include Byteback::Log - -if ENV['SSH_ORIGINAL_COMMAND'] - ARGV.concat(ENV['SSH_ORIGINAL_COMMAND'].split(' ')) -end - -byteback_host = ENV['BYTEBACK_HOST'] -fatal('BYTEBACK_HOST environment not set') unless byteback_host - -byteback_root = ENV['HOME'] + '/' + ENV['BYTEBACK_HOST'] -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] == 'restore') - ARGV[0] = 'rsync' - a = [] - ARGV.each do |tmp| - if tmp =~ /^\/(.*)/ - tmp = "#{byteback_host}/#{Regexp.last_match(1).dup}" - end - a.push(tmp) - end - exec(*a) -elsif ARGV[0] == 'rsync' - ARGV[-1] = "#{byteback_root}/current" - exec(*ARGV) -elsif ARGV[0] == 'byteback-snapshot' - ARGV.concat(['--root', "#{byteback_root}"]) - exec(*ARGV) -end - -opts = Trollop.options do - opt :verbose, 'Print diagnostics' - opt :ping, 'Check connection parameters and exit' - opt :list, 'Show backed up files matching the given pattern', type: :string - opt :restore, 'Perform a restoration operation', type: :string - opt :complete, 'Mark current backup as complete' -end - -error('Please only choose one mode') if opts[:ping] && opts[:complete] -if opts[:complete] - system('byteback-snapshot', '--root', byteback_root) -elsif opts[:list] - system("cd #{byteback_root} && find . -print | grep #{opts[:list]}") - exit(0) -elsif opts[:ping] - exit 0 -else - STDERR.print "byteback-receive failed\n" - exit 9 -end |