Class: Container::Backup::Volumes
Instance Method Summary
collapse
Methods inherited from Directories
#backup, #backup_volume, #recover_volume, #start, #stop
Methods inherited from Step
#backup, #backup_path, #container, #image, #initialize, #params, #perform
Instance Method Details
#create_volume ⇒ Object
27
28
29
|
# File 'lib/container/steps/volumes.rb', line 27
def create_volume
sh "docker volume create #{volume}"
end
|
#remove_container ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/container/steps/volumes.rb', line 5
def remove_container
puts "Remove container #{container} (y/n)?"
if gets.chomp == 'y'
sh "docker rm -f #{container}"
else
exit
end
end
|
#remove_volume ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/container/steps/volumes.rb', line 18
def remove_volume
puts "Remove volume #{volume} (y/n)?"
if gets.chomp == 'y'
sh "docker volume rm #{volume}"
else
exit
end
end
|
#restore ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/container/steps/volumes.rb', line 38
def restore
stop
remove_container
remove_volume
recover_volume
start
end
|
#tar_volume(option) ⇒ Object
33
34
35
36
|
# File 'lib/container/steps/volumes.rb', line 33
def tar_volume(option)
raise "Invalid tar option #{option}" unless option =~ /\A[cx]\z/
sh "docker run --rm -v #{volume}:/temp -v #{backup_path}:/backup ubuntu bash -c \"cd /temp && tar #{option}vf /backup/#{volume}.tar #{option == 'c' ? ' .' : ''}\""
end
|
#volume ⇒ Object
14
15
16
|
# File 'lib/container/steps/volumes.rb', line 14
def volume
@params
end
|