Module: DatedBackup::Core::Tasks
- Included in:
- DatedBackup::Core
- Defined in:
- lib/dated_backup/core/tasks.rb
Instance Method Summary collapse
- #backup_directories ⇒ Object
- #create_backup ⇒ Object
- #create_main_backup_directory ⇒ Object
- #find_latest_backup ⇒ Object (also: #latest_backup)
- #has_backup? ⇒ Boolean
- #run_tasks ⇒ Object
Instance Method Details
#backup_directories ⇒ Object
34 35 36 |
# File 'lib/dated_backup/core/tasks.rb', line 34 def backup_directories Dir.glob("#{backup_root}/*").grep(BACKUP_REGEXP) end |
#create_backup ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dated_backup/core/tasks.rb', line 11 def create_backup = has_backup? ? "--link-dest #{latest_backup} " : "" sources.each do |source| cmd = "rsync -a --delete #{}#{} #{source} #{destination}" execute cmd, kernel kernel.puts "\n\n" end end |
#create_main_backup_directory ⇒ Object
21 22 23 24 25 26 |
# File 'lib/dated_backup/core/tasks.rb', line 21 def create_main_backup_directory unless File.exists? backup_root kernel.puts "* Creating main backup directory #{backup_root}" Dir.mkdir backup_root end end |
#find_latest_backup ⇒ Object Also known as: latest_backup
28 29 30 |
# File 'lib/dated_backup/core/tasks.rb', line 28 def find_latest_backup backup_directories.sort.reverse.first end |
#has_backup? ⇒ Boolean
38 39 40 |
# File 'lib/dated_backup/core/tasks.rb', line 38 def has_backup? backup_directories.empty? ? false : true end |
#run_tasks ⇒ Object
6 7 8 9 |
# File 'lib/dated_backup/core/tasks.rb', line 6 def run_tasks create_main_backup_directory create_backup end |