vamboo 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802fc5675c15fdfde308b87ef6e29195ba247b2b
4
- data.tar.gz: 51fbbf61a237194affafbee4ae60db120eeee8a5
3
+ metadata.gz: 53ed8ee8cc83376ebbfd43f0546b118085dc62c8
4
+ data.tar.gz: f47ef0ea0c06e6c0819cbda6d39471f48adc57d9
5
5
  SHA512:
6
- metadata.gz: 732400c5a21189ff2923c5c40240782b0e75259562c86cc9fa07ff00c271855305e40faf407af70e6b7773f461ccc600d63e4b0193a95df33f3739f600fa39b1
7
- data.tar.gz: da67c1c3a1e630f67e0b9c6e976ad72228027e5aab6c39321163f43a100ce0b71cfe9eb138f4ddc1e15fdb7f0e554ec2ace9ee26c26a5e72e3228fbc2a4bef62
6
+ metadata.gz: 01c4a48325d2d8eb4d185797d171cb5f4c167e2888563e109a3f48284d0172d96f8a9f8697b42ddf4aa8ace03257bf7ef3846144ded3c173195e9a63a289a925
7
+ data.tar.gz: c94d6160e0d57a3d48f94dabf14054fbed0c61216378638e5b1e9caddd09c0adc43e3aef0494622ce519cf6496e34b8832a7f0cbcd6291d31799baaa8015f18c
data/README.md CHANGED
@@ -31,8 +31,8 @@
31
31
  require "vamboo/domainlist"
32
32
 
33
33
  DomainList.define do
34
- #add("仮想マシンのドメイン名")
35
- add("my_domay")
34
+ #add("仮想マシンのドメイン名", ローテーションの期間)
35
+ add("my_domay", 7)
36
36
  end
37
37
  ```
38
38
  ### バックアップ実行
@@ -1,3 +1,4 @@
1
+ require "date"
1
2
  require "libvirt"
2
3
  require "zlib"
3
4
  require "logger"
@@ -17,16 +18,17 @@ class DomainList
17
18
  instance_eval(&block)
18
19
  end
19
20
 
20
- def add(name)
21
- @list.push(Domain.new(name))
21
+ def add(name, rotation)
22
+ @list.push(Domain.new(name, rotation))
22
23
  end
23
24
  end
24
25
 
25
26
  class Domain
26
- attr_reader :name, :vmhd_pathes
27
+ attr_reader :name, :rotation, :vmhd_pathes
27
28
 
28
- def initialize(name)
29
+ def initialize(name, rotation)
29
30
  @name = name
31
+ @rotation = rotation
30
32
  conn = Libvirt::open("qemu:///system")
31
33
  domain = conn.lookup_domain_by_name(@name)
32
34
  xml = REXML::Document.new(domain.xml_desc)
@@ -98,7 +100,8 @@ class Domain
98
100
  end
99
101
 
100
102
  log.info("Archive")
101
- Zlib::GzipWriter.open("#{target_path}/#{@name}.tar.gz") do |archive|
103
+ file_name = "#{@name}.#{Date.today.strftime("%Y%m%d")}.tar.gz"
104
+ Zlib::GzipWriter.open("#{target_path}/#{file_name}") do |archive|
102
105
  out = Archive::Tar::Minitar::Output.new(archive)
103
106
  Find.find("#{tmp_path}") do |file|
104
107
  Archive::Tar::Minitar::pack_file(file, out)
@@ -106,7 +109,13 @@ class Domain
106
109
  out.close
107
110
  end
108
111
  FileUtils.rm_rf("#{tmp_path}")
109
-
112
+
113
+ if @rotation > 0
114
+ old = Date.today - @rotation
115
+ old_file = "#{@name}.#{old}.tar.gz"
116
+ log.info("Remove old file #{target_path}/#{old}")
117
+ FileUtils.rm_rf("#{target_path}/#{old}")
118
+ end
110
119
  log.info("Complete backup")
111
120
  end
112
121
 
@@ -1,3 +1,3 @@
1
1
  module Vamboo
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vamboo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - numa08
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-03 00:00:00.000000000 Z
12
+ date: 2015-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.2.2
125
+ rubygems_version: 2.4.5
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: virtual machine backup util