Class: PXCBackup::RemoteRepo

Inherits:
Repo
  • Object
show all
Defined in:
lib/pxcbackup/remote_repo.rb

Instance Attribute Summary

Attributes inherited from Repo

#path

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ RemoteRepo



9
10
11
12
# File 'lib/pxcbackup/remote_repo.rb', line 9

def initialize(path, options = {})
  super(path, options)
  @which.s3cmd
end

Instance Method Details

#backupsObject



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