Class: Backup::Archive
Instance Attribute Summary collapse
-
#archive_path ⇒ Object
Stores the path to the archive directory.
-
#excludes ⇒ Object
Stores an array of different paths/files to exclude.
-
#name ⇒ Object
Stores the name of the archive.
-
#paths ⇒ Object
Stores an array of different paths/files to store.
Instance Method Summary collapse
-
#add(path) ⇒ Object
Adds new paths to the @paths instance variable array.
-
#exclude(path) ⇒ Object
Adds new paths to the @excludes instance variable array.
-
#initialize(name, &block) ⇒ Archive
constructor
Takes the name of the archive and the configuration block.
-
#perform! ⇒ Object
Archives all the provided paths in to a single .tar file and places that .tar file in the folder which later will be packaged.
Methods included from CLI
Constructor Details
#initialize(name, &block) ⇒ Archive
Takes the name of the archive and the configuration block
25 26 27 28 29 30 31 32 |
# File 'lib/backup/archive.rb', line 25 def initialize(name, &block) @name = name.to_sym @paths = Array.new @excludes = Array.new @archive_path = File.join(TMP_PATH, TRIGGER, 'archive') instance_eval(&block) end |
Instance Attribute Details
#archive_path ⇒ Object
Stores the path to the archive directory
21 22 23 |
# File 'lib/backup/archive.rb', line 21 def archive_path @archive_path end |
#excludes ⇒ Object
Stores an array of different paths/files to exclude
17 18 19 |
# File 'lib/backup/archive.rb', line 17 def excludes @excludes end |
#name ⇒ Object
Stores the name of the archive
9 10 11 |
# File 'lib/backup/archive.rb', line 9 def name @name end |
#paths ⇒ Object
Stores an array of different paths/files to store
13 14 15 |
# File 'lib/backup/archive.rb', line 13 def paths @paths end |
Instance Method Details
#add(path) ⇒ Object
Adds new paths to the @paths instance variable array
36 37 38 |
# File 'lib/backup/archive.rb', line 36 def add(path) @paths << path end |
#exclude(path) ⇒ Object
Adds new paths to the @excludes instance variable array
42 43 44 |
# File 'lib/backup/archive.rb', line 42 def exclude(path) @excludes << path end |
#perform! ⇒ Object
Archives all the provided paths in to a single .tar file and places that .tar file in the folder which later will be packaged
49 50 51 52 53 |
# File 'lib/backup/archive.rb', line 49 def perform! mkdir(archive_path) Logger.("#{ self.class } started packaging and archiving #{ paths.map { |path| "\"#{path}\""}.join(", ") }.") run("#{ utility(:tar) } -c #{ paths_to_exclude } #{ paths_to_package } 1> '#{ File.join(archive_path, "#{name}.tar") }' 2> /dev/null") end |