Class: PXCBackup::RemoteRepo
Instance Attribute Summary
Attributes inherited from Repo
Instance Method Summary collapse
- #backups ⇒ Object
- #delete(backup) ⇒ Object
-
#initialize(path, options = {}) ⇒ RemoteRepo
constructor
A new instance of RemoteRepo.
- #stream_command(backup) ⇒ Object
- #sync(local_repo) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ RemoteRepo
9 10 11 12 |
# File 'lib/pxcbackup/remote_repo.rb', line 9 def initialize(path, = {}) super(path, ) @which.s3cmd end |
Instance Method Details
#backups ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pxcbackup/remote_repo.rb', line 14 def backups backups = [] output = Command.run("#{@which.s3cmd.shellescape} ls #{@path.shellescape}") output[:stdout].lines.to_a.each do |line| path = line.chomp.split[3] next unless Backup.regexp.match(path) backups << Backup.new(self, path) end backups.sort end |
#delete(backup) ⇒ Object
31 32 33 34 |
# File 'lib/pxcbackup/remote_repo.rb', line 31 def delete(backup) verify(backup) Command.run("#{@which.s3cmd.shellescape} del #{backup.path.shellescape}") end |
#stream_command(backup) ⇒ Object
36 37 38 39 |
# File 'lib/pxcbackup/remote_repo.rb', line 36 def stream_command(backup) verify(backup) "#{@which.s3cmd.shellescape} get #{backup.path.shellescape} -" end |
#sync(local_repo) ⇒ Object
25 26 27 28 29 |
# File 'lib/pxcbackup/remote_repo.rb', line 25 def sync(local_repo) source = File.join(local_repo.path, '/') target = File.join(path, '/') Command.run("#{@which.s3cmd.shellescape} sync --no-progress --delete-removed #{source.shellescape} #{target.shellescape}") end |