backupit 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ SunFunJun [http://github.com/sunfjun]
2
+ FrankYue [http://github.com/frankyue]
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  storage :file do
9
9
  path '/opt/backup/'
10
10
  mysql_check true
11
- mysql_config({:host=>"localhost",:user=>"root",:password=>"test",:databases=>"checkdb"})
11
+ mysql_config({:host=>"localhost",:user=>"root",:password=>"test",:database=>"checkdb"})
12
12
  end
13
13
 
14
14
  server 'delonghi' do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -54,15 +54,22 @@ module Backup
54
54
  tmpfile = Tempfile.new('mysql.sql')
55
55
  run_with_changes("ssh #{@ssh_host} 'mysqldump #{mysql_config} > #{tmpfile.path}'") &&
56
56
  run_with_changes("scp #{@scp_host}:#{tmpfile.path} '#{target_path}/#{key}.sql'") &&
57
- run_with_changes("ssh #{@ssh_host} 'rm #{tmpfile.path}'"))
57
+ run_with_changes("ssh #{@ssh_host} 'rm #{tmpfile.path}'")
58
58
 
59
59
  check_backuped_mysql(target_path, key) if config.mysql_check and (mysql.check || mysql.check.nil?)
60
60
  end
61
61
  end
62
62
 
63
63
  def check_backuped_mysql(target_path, key)
64
+ dbconfig = config.mysql_config
65
+
64
66
  self.changes << "DBCheck running -- checking #{target_path}/#{key}.sql #{Time.now}"
65
- status = run_with_changes("mysql -h#{config.mysql_config[:host]} -u#{config.mysql_config[:user]} #{config.mysql_config[:databases]} < #{target_path}/#{key}.sql") ? "SUCCESSFUL" : "FAILURE"
67
+
68
+ mysql_command = "mysql -h#{dbconfig[:host]} -u#{dbconfig[:user]} #{dbconfig[:password] ? "-p#{dbconfig[:password]}" : ""}"
69
+ system("#{mysql_command} -e 'drop database #{dbconfig[:database]};'")
70
+ system("#{mysql_command} -e 'create database #{dbconfig[:database]};'")
71
+
72
+ status = run_with_changes("#{mysql_command} #{dbconfig[:database]} < #{target_path}/#{key}.sql") ? "SUCCESSFUL" : "FAILURE"
66
73
  self.changes << "DBCheck finished #{status} -- #{Time.now}"
67
74
  end
68
75
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jinzhu
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-10-03 00:00:00 +08:00
17
+ date: 2011-10-04 00:00:00 +08:00
18
18
  default_executable: backup
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -40,6 +40,7 @@ extra_rdoc_files:
40
40
  - README.md
41
41
  files:
42
42
  - .document
43
+ - Contributors
43
44
  - LICENSE
44
45
  - README.md
45
46
  - Rakefile