backup 4.0.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/backup/database/sqlite.rb +15 -61
- data/lib/backup/version.rb +1 -1
- data/templates/cli/databases/sqlite +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5cc14fb63c5d6cd97bf8475a0e35977842e5699
|
4
|
+
data.tar.gz: 6592b04024a67b4595ae462d58222d223c1543b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
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
|
-
|
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
|
-
|
33
|
+
pipeline = Pipeline.new
|
34
|
+
dump_ext = 'sql'
|
54
35
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
81
|
-
|
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
|
data/lib/backup/version.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
# SQLite [Database]
|
3
3
|
#
|
4
4
|
database SQLite do |db|
|
5
|
-
#
|
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
|