Class: YOLOBackup::BackupRunner::Job
- Inherits:
-
Object
- Object
- YOLOBackup::BackupRunner::Job
- Includes:
- Helper::Log
- Defined in:
- lib/yolo_backup/backup_runner/job.rb
Constant Summary collapse
- OPTIONS =
%w{server verbose}
Instance Method Summary collapse
- #backend ⇒ Object
- #backup_required? ⇒ Boolean
-
#initialize(options) ⇒ Job
constructor
A new instance of Job.
- #maximum_backup_age ⇒ Object
- #start ⇒ Object
Methods included from Helper::Log
Constructor Details
Instance Method Details
#backend ⇒ Object
56 57 58 |
# File 'lib/yolo_backup/backup_runner/job.rb', line 56 def backend @backend ||= YOLOBackup::BackupRunner::Backend::Rsync.new(server) end |
#backup_required? ⇒ Boolean
36 37 38 39 |
# File 'lib/yolo_backup/backup_runner/job.rb', line 36 def backup_required? latest_backup = server.latest_backup return latest_backup.nil? || latest_backup < maximum_backup_age end |
#maximum_backup_age ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/yolo_backup/backup_runner/job.rb', line 41 def maximum_backup_age case server.rotation.minimum_unit when 'hourly' 1.hour.ago when 'daily' 1.day.ago when 'weekly' 1.week.ago when 'monthly' 1.month.ago when 'yearly' 1.year.ago end end |
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yolo_backup/backup_runner/job.rb', line 23 def start if backup_required? log "Latest backup (#{server.latest_backup}) is older than maximum backup age (#{maximum_backup_age})" if verbose? log "Starting backup of #{server}" backend.start_backup log "Backup completed" if verbose? log "Cleaning up old backups" if verbose? log "Deleted #{server.cleanup_backups.length} backups" if verbose? else log "Backup not required (latest backup = #{server.latest_backup}, maximum backup age = #{maximum_backup_age})" if verbose? end end |