Commit 9e6fc8b5269f8583e88c67c7cdc356f76a8237ed
1 parent
68590fdd
Exists in
spb-stable
and in
3 other branches
Report failure of DB backup commands
Showing
1 changed file
with
16 additions
and
2 deletions
Show diff stats
lib/backup/database.rb
... | ... | @@ -11,23 +11,29 @@ module Backup |
11 | 11 | end |
12 | 12 | |
13 | 13 | def dump |
14 | - case config["adapter"] | |
14 | + success = case config["adapter"] | |
15 | 15 | when /^mysql/ then |
16 | + print "Dumping MySQL database #{config['database']} ... " | |
16 | 17 | system('mysqldump', *mysql_args, config['database'], out: db_file_name) |
17 | 18 | when "postgresql" then |
19 | + print "Dumping PostgreSQL database #{config['database']} ... " | |
18 | 20 | pg_env |
19 | 21 | system('pg_dump', config['database'], out: db_file_name) |
20 | 22 | end |
23 | + report_success(success) | |
21 | 24 | end |
22 | 25 | |
23 | 26 | def restore |
24 | - case config["adapter"] | |
27 | + success = case config["adapter"] | |
25 | 28 | when /^mysql/ then |
29 | + print "Restoring MySQL database #{config['database']} ... " | |
26 | 30 | system('mysql', *mysql_args, config['database'], in: db_file_name) |
27 | 31 | when "postgresql" then |
32 | + print "Restoring PostgreSQL database #{config['database']} ... " | |
28 | 33 | pg_env |
29 | 34 | system('psql', config['database'], '-f', db_file_name) |
30 | 35 | end |
36 | + report_success(success) | |
31 | 37 | end |
32 | 38 | |
33 | 39 | protected |
... | ... | @@ -54,5 +60,13 @@ module Backup |
54 | 60 | ENV['PGPORT'] = config["port"].to_s if config["port"] |
55 | 61 | ENV['PGPASSWORD'] = config["password"].to_s if config["password"] |
56 | 62 | end |
63 | + | |
64 | + def report_success(success) | |
65 | + if success | |
66 | + puts '[DONE]'.green | |
67 | + else | |
68 | + puts '[FAILED]'.red | |
69 | + end | |
70 | + end | |
57 | 71 | end |
58 | 72 | end | ... | ... |