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

Returns a new instance of RemoteRepo.



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

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

Instance Method Details

#backupsObject



13
14
15
16
17
18
19
20
21
# File 'lib/pxcbackup/remote_repo.rb', line 13

def backups
  backups = []
  `#{@which.s3cmd.shellescape} ls #{@path.shellescape}`.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



29
30
31
32
# File 'lib/pxcbackup/remote_repo.rb', line 29

def delete(backup)
  verify(backup)
  system("#{@which.s3cmd.shellescape} del #{backup.path.shellescape} > /dev/null")
end

#stream_command(backup) ⇒ Object



34
35
36
37
# File 'lib/pxcbackup/remote_repo.rb', line 34

def stream_command(backup)
  verify(backup)
  "#{@which.s3cmd.shellescape} get #{backup.path.shellescape} -"
end

#sync(local_repo) ⇒ Object



23
24
25
26
27
# File 'lib/pxcbackup/remote_repo.rb', line 23

def sync(local_repo)
  source = File.join(local_repo.path, '/')
  target = File.join(path, '/')
  system("#{@which.s3cmd.shellescape} sync --no-progress --delete-removed #{source.shellescape} #{target.shellescape} > /dev/null")
end