Class: Rbk::Backup
- Inherits:
-
Object
- Object
- Rbk::Backup
- Defined in:
- lib/rbk/backup.rb
Instance Method Summary collapse
-
#initialize(repos, git, archiver, uploader, shell, fileutils = FileUtils) ⇒ Backup
constructor
A new instance of Backup.
- #run ⇒ Object
Constructor Details
#initialize(repos, git, archiver, uploader, shell, fileutils = FileUtils) ⇒ Backup
5 6 7 8 9 10 11 12 13 |
# File 'lib/rbk/backup.rb', line 5 def initialize(repos, git, archiver, uploader, shell, fileutils=FileUtils) @repos = repos @git = git @archiver = archiver @uploader = uploader @shell = shell @fileutils = fileutils @date_suffix = Date.today.strftime('%Y%m%d') end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rbk/backup.rb', line 15 def run @repos.each do |repo| clone_path = %(#{repo.name}-#{@date_suffix}.git) @shell.puts(%(Cloning "#{repo.name}" to "#{clone_path}")) if cloned?(repo.ssh_url, clone_path) archive = @archiver.create(clone_path) @uploader.upload(archive) @fileutils.remove_entry_secure(archive) @fileutils.remove_entry_secure(clone_path) else @shell.puts(%(Failed to clone "#{repo.name}")) end end end |