backy_rb 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/backy/pg_restore.rb +18 -18
- data/lib/backy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c60d417618b6d91862bf0de81b3dc88cdd61af8bc5854f498ffc6bad749727
|
4
|
+
data.tar.gz: cbf338342040184c61bcbeffbec63c6a9479e4f370beea2e217cac3b2a1e0c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ccce1e737f6e34b4e0f4f6b686974dc7341ae1c29e4a0bbe70582ef597502160edb6e5beee657d8df58e82b3f4900f85570a5fe67f37eb974c98641453202d
|
7
|
+
data.tar.gz: 8565246f494bb1302aa947a8ef8623aa4f5d7b2c225931a8342ec46eb24d27e904bcf5183a680baff0299c19ceaf863888260bce8f52caf7f7b73b74cc2cae70
|
data/lib/backy/pg_restore.rb
CHANGED
@@ -15,11 +15,11 @@ module Backy
|
|
15
15
|
use_multicore = ENV["BACKY_USE_PARALLEL"] == "true"
|
16
16
|
|
17
17
|
if pigz_installed && multicore && use_multicore
|
18
|
-
|
18
|
+
Logger.log('Using parallel restore with pigz')
|
19
19
|
parallel_restore
|
20
20
|
else
|
21
|
-
|
22
|
-
|
21
|
+
Logger.log("Pigz not installed or system is not multicore")
|
22
|
+
Logger.log('Using plain text restore')
|
23
23
|
plain_text_restore
|
24
24
|
end
|
25
25
|
end
|
@@ -31,11 +31,11 @@ module Backy
|
|
31
31
|
def plain_text_restore
|
32
32
|
cmd = "(#{pg_password_env}psql -c \"#{terminate_connection_sql};\" #{pg_credentials} #{database}; #{pg_password_env}dropdb #{pg_credentials} #{database}; #{pg_password_env}createdb #{pg_credentials} #{database}; gunzip -c #{file_name} | #{pg_password_env}psql #{pg_credentials} -q -d #{database}) 2>&1 >> #{log_file}"
|
33
33
|
|
34
|
-
|
34
|
+
Logger.log("Restoring #{database} from #{file_name} ...")
|
35
35
|
if system(cmd)
|
36
|
-
|
36
|
+
Logger.log("Database restoration completed successfully.")
|
37
37
|
else
|
38
|
-
|
38
|
+
Logger.log("Database restoration failed. See #{log_file} for details.")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -50,40 +50,40 @@ module Backy
|
|
50
50
|
# Terminate connections and drop/create database
|
51
51
|
terminate_and_recreate_db = "(#{pg_password_env}psql -c \"#{terminate_connection_sql};\" #{pg_credentials} #{database}; #{pg_password_env}dropdb #{pg_credentials} #{database}; #{pg_password_env}createdb #{pg_credentials} #{database}) 2>&1 >> #{log_file}"
|
52
52
|
|
53
|
-
|
53
|
+
Logger.log("Terminating connections to #{database}")
|
54
54
|
if system(terminate_and_recreate_db)
|
55
|
-
|
55
|
+
Logger.log("Database connections terminated and database recreated.")
|
56
56
|
else
|
57
|
-
|
57
|
+
Logger.log("Error during database termination and recreation. See #{log_file}")
|
58
58
|
return
|
59
59
|
end
|
60
60
|
|
61
61
|
# Decompress and restore
|
62
|
-
|
62
|
+
Logger.log("Decompressing #{file_name} into #{dump_dir} ...")
|
63
63
|
if system(decompress_cmd)
|
64
|
-
|
64
|
+
Logger.log("Decompression completed successfully.")
|
65
65
|
|
66
66
|
# Check the expected file
|
67
67
|
unless File.exist?("#{dump_dir}/toc.dat")
|
68
|
-
|
68
|
+
Logger.log("toc.dat not found in #{dump_dir}.")
|
69
69
|
return
|
70
70
|
end
|
71
71
|
else
|
72
|
-
|
72
|
+
Logger.log("Decompression failed. See #{log_file} for details.")
|
73
73
|
return
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
Logger.log("Restoring database from #{dump_dir} ...")
|
77
77
|
if system(restore_cmd)
|
78
|
-
|
78
|
+
Logger.log("Database restoration completed successfully.")
|
79
79
|
else
|
80
|
-
|
80
|
+
Logger.log("Database restoration failed. See #{log_file} for details.")
|
81
81
|
return
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
Logger.log("Cleanup: Removing #{dump_dir} ...")
|
85
85
|
FileUtils.rm_rf(dump_dir)
|
86
|
-
|
86
|
+
Logger.log("Cleanup completed.")
|
87
87
|
end
|
88
88
|
|
89
89
|
def terminate_connection_sql
|
data/lib/backy/version.rb
CHANGED