Class: DatedBackup::Core
- Inherits:
-
Object
- Object
- DatedBackup::Core
- Includes:
- CommandLine, Tasks
- Defined in:
- lib/dated_backup/core/tasks.rb,
lib/dated_backup/core/backup_set.rb,
lib/dated_backup/core/command_line.rb,
lib/dated_backup/core/dated_backup.rb,
lib/dated_backup/core/backup_remover.rb
Defined Under Namespace
Modules: CommandLine, Tasks Classes: BackupRemover, BackupSet
Constant Summary collapse
- BACKUP_REGEXP =
/[12][0-9]{3}\-[01][0-9]\-[0-3][0-9]\-[0-2][0-9]h\-[0-6][0-9]m\-[0-6][0-9]s/
Instance Attribute Summary collapse
-
#after_run ⇒ Object
readonly
Returns the value of attribute after_run.
-
#backup_root ⇒ Object
Returns the value of attribute backup_root.
-
#before_run ⇒ Object
readonly
Returns the value of attribute before_run.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#kernel ⇒ Object
readonly
Returns the value of attribute kernel.
-
#options ⇒ Object
Returns the value of attribute options.
-
#pre_run_commands ⇒ Object
readonly
Returns the value of attribute pre_run_commands.
-
#sources ⇒ Object
Returns the value of attribute sources.
-
#user_domain ⇒ Object
Returns the value of attribute user_domain.
Instance Method Summary collapse
- #check_for_directory_errors ⇒ Object
-
#initialize(procs = {}, kernel = Kernel) ⇒ Core
constructor
A new instance of Core.
-
#run ⇒ Object
create the first backup, if non-existent otherwise cp -al (or # replace cp -al a b with cd a && find . -print | cpio -dpl ../b ) and then create the backup of the dirs using rsync -a –delete the files, in the end, should be read only and undeletable.
- #set_attributes(h = {}) ⇒ Object
Methods included from Tasks
#backup_directories, #create_backup, #create_main_backup_directory, #find_latest_backup, #has_backup?, #run_tasks
Methods included from CommandLine
Constructor Details
#initialize(procs = {}, kernel = Kernel) ⇒ Core
Returns a new instance of Core.
14 15 16 17 18 |
# File 'lib/dated_backup/core/dated_backup.rb', line 14 def initialize(procs={}, kernel=Kernel) @kernel = kernel @before_run = procs[:before] || Proc.new {} @after_run = procs[:after] || Proc.new {} end |
Instance Attribute Details
#after_run ⇒ Object (readonly)
Returns the value of attribute after_run.
12 13 14 |
# File 'lib/dated_backup/core/dated_backup.rb', line 12 def after_run @after_run end |
#backup_root ⇒ Object
Returns the value of attribute backup_root.
10 11 12 |
# File 'lib/dated_backup/core/dated_backup.rb', line 10 def backup_root @backup_root end |
#before_run ⇒ Object (readonly)
Returns the value of attribute before_run.
12 13 14 |
# File 'lib/dated_backup/core/dated_backup.rb', line 12 def before_run @before_run end |
#destination ⇒ Object
Returns the value of attribute destination.
10 11 12 |
# File 'lib/dated_backup/core/dated_backup.rb', line 10 def destination @destination end |
#kernel ⇒ Object (readonly)
Returns the value of attribute kernel.
11 12 13 |
# File 'lib/dated_backup/core/dated_backup.rb', line 11 def kernel @kernel end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/dated_backup/core/dated_backup.rb', line 10 def @options end |
#pre_run_commands ⇒ Object (readonly)
Returns the value of attribute pre_run_commands.
11 12 13 |
# File 'lib/dated_backup/core/dated_backup.rb', line 11 def pre_run_commands @pre_run_commands end |
#sources ⇒ Object
Returns the value of attribute sources.
10 11 12 |
# File 'lib/dated_backup/core/dated_backup.rb', line 10 def sources @sources end |
#user_domain ⇒ Object
Returns the value of attribute user_domain.
10 11 12 |
# File 'lib/dated_backup/core/dated_backup.rb', line 10 def user_domain @user_domain end |
Instance Method Details
#check_for_directory_errors ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/dated_backup/core/dated_backup.rb', line 28 def check_for_directory_errors if sources.nil? || sources.empty? raise DirectoryError, "No source directory given" elsif backup_root.nil? || backup_root.empty? raise DirectoryError, "No destination directory given" end end |
#run ⇒ Object
create the first backup, if non-existent
otherwise cp -al (or # replace cp -al a b with cd a && find . -print | cpio -dpl ../b ) and then create the backup of the dirs using rsync -a –delete the files, in the end, should be read only and undeletable
40 41 42 43 44 |
# File 'lib/dated_backup/core/dated_backup.rb', line 40 def run DatedBackup::ExecutionContext.new :before, &@before_run run_tasks DatedBackup::ExecutionContext.new :after, &@after_run end |
#set_attributes(h = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dated_backup/core/dated_backup.rb', line 20 def set_attributes(h={}) (h) @destination = generate_backup_filename if @user_domain @sources.map! { |src| "#{@user_domain}:#{src}" } end end |