Sha256: a449e59f76e52d26fe67015d36b3aac693197f6aebd4818e96db1df2092c4065
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'yolo_backup/backup_runner/backend' class YOLOBackup::BackupRunner::Backend::Rsync < YOLOBackup::BackupRunner::Backend class Error < StandardError; end DEFAULT_RSYNC_OPTIONS = '-aAX --numeric-ids' attr_reader :server def initialize(server) @server = server end def start_backup server.storage.initiate_backup(server) do |path| options = [DEFAULT_RSYNC_OPTIONS] if server.latest_backup latest_backup = File.expand_path("#{path}/../#{server.latest_backup}") options << "--link-dest='#{latest_backup}'" end ssh_options = [] ssh_options << "-i '#{server.ssh_key}'" unless server.ssh_key.nil? ssh_options << "-p '#{server.ssh_port}'" unless server.ssh_port.nil? options << "-e \"ssh #{ssh_options.join(' ')}\"" command = "rsync #{options.join(' ')} #{server.ssh_user || 'root'}@#{server.ssh_host || server}:/ '#{path}'" puts command output = `#{command}` raise Error, "rsync command failed: #{$?}" unless $?.success? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yolo_backup-0.0.0 | lib/yolo_backup/backup_runner/backend/rsync.rb |