Module: BackupParadise::Windows

Defined in:
lib/backup_paradise/windows/windows.rb

Overview

BackupParadise::Windows

Class Method Summary collapse

Class Method Details

.backup_ingrid_directory(from = 'c://ingrid/.', to = :infer_the_first_external_device) ⇒ Object

#

BackupParadise::Windows.backup_ingrid_directory

This will try to backup c:\ingrid. It only works on windows really.

The trailing ‘.’ is necessary, so that the content of the directory is copied, rather than the directory itself and THEN its content.

#


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/backup_paradise/windows/windows.rb', line 46

def self.backup_ingrid_directory(
    from = 'c://ingrid/.',
    to   = :infer_the_first_external_device
  )
  case to
  # ======================================================================= #
  # === :infer_the_first_external_device
  #
  # Here we will infer which external device is the first one.
  # ======================================================================= #
  when :infer_the_first_external_device
    begin
      require 'mountpoints'
    rescue LoadError; end
    if Object.const_defined? :Mountpoints
      to = Mountpoints[]
    else # else we will use a hardcoded approach.
      e 'Assuming a hardcoded path at: e://'
      to = "e://"
    end
  end
  if to.is_a? Array
    to = to.first
  end
  unless to.include? '_'
    from = from.to_s.dup
    from.chop! if from.end_with? '/'
    if from.start_with?('c://') and BackupParadise.are_we_on_linux?
      from[0,4] = ''
    end
    _ = to.to_s+
        File.basename(from.to_s.delete('.'))+ # We remove '.' to avoid "ingrid/." stuff.
        '_'+
        return_the_current_time
    _ = _.squeeze '/'
    e 'Now creating the directory '+_+'.'
    FileUtils.mkdir_p(_)
    to = _
  end
  if File.directory?(from) and !from.end_with?('/', '.')
    from = from.dup if from.frozen?
    from << '/'
  end
  if File.directory?(to) and !to.end_with?('/')
    to = to.dup if to.frozen?
    to << '/'
  end
  do_use_fileutils_for_the_copy_action
  BackupParadise.simple_backup(from, to)
end

.do_use_fileutils_for_the_copy_actionObject

#

BackupParadise.do_use_fileutils_for_the_copy_action

#


34
35
36
# File 'lib/backup_paradise/windows/windows.rb', line 34

def self.do_use_fileutils_for_the_copy_action
  BackupParadise::CONFIG['use_system_cp'] = false
end

.e(i = '') ⇒ Object

#

BackupParadise::Windows.e

#


20
21
22
# File 'lib/backup_paradise/windows/windows.rb', line 20

def self.e(i = '')
  puts i
end

.return_the_current_timeObject

#

BackupParadise::Windows.return_the_current_time

#


27
28
29
# File 'lib/backup_paradise/windows/windows.rb', line 27

def self.return_the_current_time
  Time.now.strftime('%d.%m.%Y')
end