backy_rb 0.1.4 → 0.1.6

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
  SHA256:
3
- metadata.gz: 976aef5ff1edf205faaa2494ddbf2e7a52ee40437b85f2b4a7e9b5cc46cdfef1
4
- data.tar.gz: b8774cee38066ddcc000d916e204573a08c07cef91f1d5e809521e990e3a299e
3
+ metadata.gz: 5869c45131402a06e9bd79a71e3cc82a3a0e867006fa9fa9b9f46bb7f1bd60b8
4
+ data.tar.gz: 614e88a654a7fd62d4426f8bbe1966ac3727229dbfe3d38dd5b171ae76e0bd9f
5
5
  SHA512:
6
- metadata.gz: d786dd5a26d31bc9a7d17c68bd1dff4f796ce50860c900e302cedb55442b4493a62f00ef5103cd0c019052fa16a06f90b2c9d05e97c597c74dc145210537c357
7
- data.tar.gz: df6656391c48a16172ef5dcaded48df92228f690c0a137c752fc879012542317ceb62a97f71cb721f0d21241ffb9838f2830815a2659525067cae1d6a31f899a
6
+ metadata.gz: c731f5764a173ba08cae49dc3abf6b4212b4b9b5f66757849b88b9be49511c13cd92fe8d64fb65e468992108b32ac877e1c2049afb5d390d8529f29092e746c4
7
+ data.tar.gz: 6e068f09ffaecbe95b9857cd947584a86ba3c0b18b70698cb709b91aa0711706de950121d47dbd03af91d0d3e610d790c2317296e742fcdf7e56456721f76abe
data/lib/backy/cli.rb CHANGED
@@ -20,7 +20,7 @@ module Backy
20
20
  file_name = Backy::PgDump.new.call
21
21
  save_to_s3(file_name)
22
22
  File.delete(file_name) if File.exist?(file_name)
23
- Logger.sucess("Dump pushed to S3 and local file deleted.")
23
+ Logger.success("Dump pushed to S3 and local file deleted.")
24
24
  end
25
25
 
26
26
  desc "upload", "Upload a specific file to S3"
@@ -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
- log_message('Using parallel restore with pigz')
18
+ Logger.log('Using parallel restore with pigz')
19
19
  parallel_restore
20
20
  else
21
- log_message("Pigz not installed or system is not multicore")
22
- log_message('Using plain text restore')
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
- log_message("Restoring #{database} from #{file_name} ...")
34
+ Logger.log("Restoring #{database} from #{file_name} ...")
35
35
  if system(cmd)
36
- log_message("Database restoration completed successfully.")
36
+ Logger.log("Database restoration completed successfully.")
37
37
  else
38
- log_message("Database restoration failed. See #{log_file} for details.")
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
- log_message("Terminating connections to #{database}")
53
+ Logger.log("Terminating connections to #{database}")
54
54
  if system(terminate_and_recreate_db)
55
- log_message("Database connections terminated and database recreated.")
55
+ Logger.log("Database connections terminated and database recreated.")
56
56
  else
57
- log_message("Error during database termination and recreation. See #{log_file}")
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
- log_message("Decompressing #{file_name} into #{dump_dir} ...")
62
+ Logger.log("Decompressing #{file_name} into #{dump_dir} ...")
63
63
  if system(decompress_cmd)
64
- log_message("Decompression completed successfully.")
64
+ Logger.log("Decompression completed successfully.")
65
65
 
66
66
  # Check the expected file
67
67
  unless File.exist?("#{dump_dir}/toc.dat")
68
- log_message("toc.dat not found in #{dump_dir}.")
68
+ Logger.log("toc.dat not found in #{dump_dir}.")
69
69
  return
70
70
  end
71
71
  else
72
- log_message("Decompression failed. See #{log_file} for details.")
72
+ Logger.log("Decompression failed. See #{log_file} for details.")
73
73
  return
74
74
  end
75
75
 
76
- log_message("Restoring database from #{dump_dir} ...")
76
+ Logger.log("Restoring database from #{dump_dir} ...")
77
77
  if system(restore_cmd)
78
- log_message("Database restoration completed successfully.")
78
+ Logger.log("Database restoration completed successfully.")
79
79
  else
80
- log_message("Database restoration failed. See #{log_file} for details.")
80
+ Logger.log("Database restoration failed. See #{log_file} for details.")
81
81
  return
82
82
  end
83
83
 
84
- log_message("Cleanup: Removing #{dump_dir} ...")
84
+ Logger.log("Cleanup: Removing #{dump_dir} ...")
85
85
  FileUtils.rm_rf(dump_dir)
86
- log_message("Cleanup completed.")
86
+ Logger.log("Cleanup completed.")
87
87
  end
88
88
 
89
89
  def terminate_connection_sql
data/lib/backy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Backy
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backy_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Kharchenko