Class: S3Rotate::BackupManager
- Inherits:
-
Object
- Object
- S3Rotate::BackupManager
- Defined in:
- lib/s3_rotate/core/backup_manager.rb
Instance Attribute Summary collapse
-
#rotator ⇒ Object
Returns the value of attribute rotator.
-
#s3_client ⇒ Object
attributes.
-
#uploader ⇒ Object
Returns the value of attribute uploader.
Instance Method Summary collapse
-
#initialize(key, secret, bucket, region) ⇒ Object
constructor
Initialize a new BackupManager instance.
-
#rotate(backup_name, local_backups_dir, max_local = 3, max_daily = 7, max_weekly = 4, max_monthly = 3) ⇒ Object
Rotate files (local, daily, weekly, monthly) and apply maximum limits for each type.
-
#upload(backup_name, local_backups_path, date_regex = /\d{4}-\d{2}-\d{2}/, date_format = "%Y-%m-%d") ⇒ Object
Upload local backup files to AWS S3 Only uploads new backups Only uploads backups as daily backups: use ‘rotate` to generate the weekly & monthly files.
Constructor Details
#initialize(key, secret, bucket, region) ⇒ Object
Initialize a new BackupManager instance.
23 24 25 26 27 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 23 def initialize(key, secret, bucket, region) @s3_client = S3Client.new(key, secret, bucket, region) @uploader = BackupUploader.new(@s3_client) @rotator = BackupRotator.new(@s3_client) end |
Instance Attribute Details
#rotator ⇒ Object
Returns the value of attribute rotator.
11 12 13 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 11 def rotator @rotator end |
#s3_client ⇒ Object
attributes
9 10 11 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 9 def s3_client @s3_client end |
#uploader ⇒ Object
Returns the value of attribute uploader.
10 11 12 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 10 def uploader @uploader end |
Instance Method Details
#rotate(backup_name, local_backups_dir, max_local = 3, max_daily = 7, max_weekly = 4, max_monthly = 3) ⇒ Object
Rotate files (local, daily, weekly, monthly) and apply maximum limits for each type
57 58 59 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 57 def rotate(backup_name, local_backups_dir, max_local=3, max_daily=7, max_weekly=4, max_monthly=3) @rotator.rotate(backup_name, local_backups_dir, max_local, max_daily, max_weekly, max_monthly) end |
#upload(backup_name, local_backups_path, date_regex = /\d{4}-\d{2}-\d{2}/, date_format = "%Y-%m-%d") ⇒ Object
Upload local backup files to AWS S3 Only uploads new backups Only uploads backups as daily backups: use ‘rotate` to generate the weekly & monthly files
41 42 43 |
# File 'lib/s3_rotate/core/backup_manager.rb', line 41 def upload(backup_name, local_backups_path, date_regex=/\d{4}-\d{2}-\d{2}/, date_format="%Y-%m-%d") @uploader.upload(backup_name, local_backups_path, date_regex, date_format) end |