backup 4.0.7 → 4.1.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: e7bc86c4dc89353c401df759462b0ba4348b707f
4
- data.tar.gz: 3e08c40c56ec68a4dd60f7fa4f06f57d20f54965
3
+ metadata.gz: f5cc14fb63c5d6cd97bf8475a0e35977842e5699
4
+ data.tar.gz: 6592b04024a67b4595ae462d58222d223c1543b5
5
5
  SHA512:
6
- metadata.gz: 3f2f379cfd4b36b326487b9688c15d9eafc2c99f3676482b7773a9c79bbbd123396bc44b4f2535bd4cf8a483b8ff07d20cbd7b16359485f12d805dbb435b1217
7
- data.tar.gz: 97c930d5f9dc687948e85b3cd622b47763af7d4cb86eff7edecd4f59e52ed9a2c481f6659f261a8c755ffae83cb927cd35a8ee236b8bf91ce61f18e86b47b23e
6
+ metadata.gz: a5122220d4ffc49fd79379518ed82ee3a2ef27dc0d26e3dc5155f25aa7e24df67883e0d84f32afb0e73a27f03e63e691c8c6229b2d7bf7a1df0e756308ea0628
7
+ data.tar.gz: dedc04a2a0a1d426bc5756e19e972c65657cdb3567cfed497b57fe449d6341e665fc44273430c985b97193117dfdf5a130a74adaef98d87d339d7337b99acdf4
@@ -6,10 +6,7 @@ module Backup
6
6
  class Error < Backup::Error; end
7
7
 
8
8
  ##
9
- # Name of the database that needs to get dumped
10
- attr_accessor :name
11
-
12
- # path option
9
+ # Path to the sqlite3 file
13
10
  attr_accessor :path
14
11
 
15
12
  ##
@@ -22,7 +19,6 @@ module Backup
22
19
  super
23
20
  instance_eval(&block) if block_given?
24
21
 
25
- @name ||= :all
26
22
  @sqlitedump_utility ||= utility(:sqlitedump)
27
23
  end
28
24
 
@@ -32,72 +28,30 @@ module Backup
32
28
  def perform!
33
29
  super
34
30
 
35
- dumps = sqlitedump
36
- db_name_list = db_names
37
-
38
- dumps.each_with_index do |dump, i|
39
- pipeline = Pipeline.new
40
- dump_ext = 'sql'
41
-
42
- pipeline << dump
43
- if @model.compressor
44
- @model.compressor.compress_with do |command, ext|
45
- pipeline << command
46
- dump_ext << ext
47
- end
48
- end
49
-
50
- dump_filename = db_name_list[i]
51
- pipeline << "cat > '#{ File.join(@dump_path, dump_filename) }.#{ dump_ext }'"
31
+ dump = "echo '.dump' | #{ sqlitedump_utility } #{ path }"
52
32
 
53
- pipeline.run
33
+ pipeline = Pipeline.new
34
+ dump_ext = 'sql'
54
35
 
55
- if pipeline.success?
56
- log!(:finished)
57
- else
58
- raise Error,
59
- "#{ database_name } Dump Failed!\n" + pipeline.error_messages
36
+ pipeline << dump
37
+ if model.compressor
38
+ model.compressor.compress_with do |command, ext|
39
+ pipeline << command
40
+ dump_ext << ext
60
41
  end
61
-
62
- i += 1
63
42
  end
64
- end
65
43
 
66
- private
44
+ pipeline << "cat > '#{ File.join( dump_path , dump_filename) }.#{ dump_ext }'"
67
45
 
68
- ##
69
- # Builds the full SQLite dump string based on all attributes
70
- def sqlitedump
71
- db_names.map { |n| "echo '.dump' | #{ sqlitedump_utility } #{ db_path }#{ n }" }
72
- end
46
+ pipeline.run
73
47
 
74
- ##
75
- # Returns the database path and adds a / at the end if not present
76
- def db_path
77
- if path.length >= 1 && path[-1, 1] != "/"
78
- "#{path}/"
48
+ if pipeline.success?
49
+ log!(:finished)
79
50
  else
80
- path
81
- end
82
- end
83
-
84
- ##
85
- # Returns the database names to use in the SQLite dump command.
86
- def db_names
87
- if @all_dbs.nil?
88
- @all_dbs = Dir.new(path).entries.select{|f| /.*.sqlite3$/.match(f)}
51
+ raise Error,
52
+ "#{ database_name } Dump Failed!\n" + pipeline.error_messages
89
53
  end
90
- dump_all? ? @all_dbs : Array(name)
91
54
  end
92
-
93
- ##
94
- # Return true if we're dumping all databases.
95
- # `name` will be set to :all if it is not set,
96
- # so this will be true by default
97
- def dump_all?
98
- name == :all
99
- end
100
-
101
55
  end
102
56
  end
103
57
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '4.0.7'
4
+ VERSION = '4.1.0'
5
5
  end
@@ -2,9 +2,9 @@
2
2
  # SQLite [Database]
3
3
  #
4
4
  database SQLite do |db|
5
- # To dump all databases, set `db.name = :all` (or leave blank)
6
- db.name = "my_database_name"
7
- db.path = "/path/to/my/sqlite/db"
5
+ # Database name and path
6
+ db.name = "my_database_name.sqlite3"
7
+ db.path = "/path/to/my/sqlite/db/"
8
8
 
9
9
  # Optional: Use to set the location of this utility
10
10
  # if it cannot be found by name in your $PATH
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen