22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/raz/restorer.rb', line 22
def restore
@info = YAML.load(File.read(File.join(@source_path, BACKUP_INFO_BASE_PATH)))
@orig_home_path = @info[:env]['HOME']
config = ConfigFile.new(backup_config_file_path(@source_path))
(config.procs[:before_restore] || []).each do |proc|
instance_eval &proc
end
@info[:copied_paths].each do |src|
dest = destination_path_from_original(src)
src = File.join(@source_path, BACKUP_DATA_BASE_PATH, src)
if File.directory?(dest)
FileOperations.dir_entries(src).each do |item|
puts "Restoring file to #{File.join(dest, item)}".green
FileOperations.copy_item(File.join(src, item), dest)
end
else
FileUtils.rmtree(dest) if File.exist?(dest)
FileUtils.mkdir_p(File.dirname(dest))
puts "Restoring item to #{dest}".green
FileOperations.copy_item(src, dest)
end
end
orig_config_path = destination_path_from_original(@info[:orig_config_path])
FileUtils.mkdir_p(File.dirname(orig_config_path))
FileOperations.copy_item(config.path, orig_config_path)
(config.procs[:after_restore] || []).each do |proc|
instance_eval &proc
end
end
|