class Container::Backup::Volumes
Public Instance Methods
create_volume()
click to toggle source
# File lib/container/steps/volumes.rb, line 27 def create_volume sh "docker volume create #{volume}" end
remove_container()
click to toggle source
-
“backup={volumes: [influxdb_data],databases: [influxdb: {user: ${INFLUXDB_ADMIN_USER},password: ${INFLUXDB_ADMIN_PASSWORD}}]}”
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/container/steps/volumes.rb, line 38 def restore stop remove_container remove_volume recover_volume start end
tar_volume(option)
click to toggle source
blog.ssdnodes.com/blog/docker-backup-volumes/
# 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()
click to toggle source
# File lib/container/steps/volumes.rb, line 14 def volume @params end