Class: GDK::Backup
- Inherits:
-
Object
- Object
- GDK::Backup
- Defined in:
- lib/gdk/backup.rb
Constant Summary collapse
- SourceFileOutsideOfGdk =
Class.new(StandardError)
- SourceFileDoesntExist =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
Class Method Summary collapse
Instance Method Summary collapse
- #backup!(advise: true) ⇒ Object
- #destination_file ⇒ Object
-
#initialize(source_file) ⇒ Backup
constructor
A new instance of Backup.
- #recover_cmd_string ⇒ Object
- #relative_source_file ⇒ Object
Constructor Details
#initialize(source_file) ⇒ Backup
Returns a new instance of Backup.
16 17 18 19 20 |
# File 'lib/gdk/backup.rb', line 16 def initialize(source_file) @source_file = Pathname.new(source_file.to_s). validate! end |
Instance Attribute Details
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
10 11 12 |
# File 'lib/gdk/backup.rb', line 10 def source_file @source_file end |
Class Method Details
Instance Method Details
#backup!(advise: true) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/gdk/backup.rb', line 22 def backup!(advise: true) ensure_backup_directory_exists make_backup_of_source_file advise_user if advise true end |
#destination_file ⇒ Object
30 31 32 |
# File 'lib/gdk/backup.rb', line 30 def destination_file @destination_file ||= backup_root.join("#{relative_source_file.to_s.gsub('/', '__')}.#{Time.now.strftime('%Y%m%d%H%M%S')}") end |
#recover_cmd_string ⇒ Object
38 39 40 41 42 43 |
# File 'lib/gdk/backup.rb', line 38 def recover_cmd_string <<~CMD cp -f '#{destination_file}' \\ '#{source_file}' CMD end |