diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-24 15:27:48 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-24 15:27:48 +0400 |
commit | d1d138562a347ec78f0331d5242e28fbb368bad0 (patch) | |
tree | 29ef6908eea9398aaa21b697db010099299309e4 /lib | |
parent | 9bb9267482cabaaaed70650929e4521527025494 (diff) | |
parent | 9e6fc8b5269f8583e88c67c7cdc356f76a8237ed (diff) |
Merge branch 'report_backup_db_success' into 'master'
Report success/failure of DB backup commands
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup/database.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 7af7140246a..ebb4f289c52 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -11,23 +11,29 @@ module Backup end def dump - case config["adapter"] + success = case config["adapter"] when /^mysql/ then + print "Dumping MySQL database #{config['database']} ... " system('mysqldump', *mysql_args, config['database'], out: db_file_name) when "postgresql" then + print "Dumping PostgreSQL database #{config['database']} ... " pg_env system('pg_dump', config['database'], out: db_file_name) end + report_success(success) end def restore - case config["adapter"] + success = case config["adapter"] when /^mysql/ then + print "Restoring MySQL database #{config['database']} ... " system('mysql', *mysql_args, config['database'], in: db_file_name) when "postgresql" then + print "Restoring PostgreSQL database #{config['database']} ... " pg_env system('psql', config['database'], '-f', db_file_name) end + report_success(success) end protected @@ -54,5 +60,13 @@ module Backup ENV['PGPORT'] = config["port"].to_s if config["port"] ENV['PGPASSWORD'] = config["password"].to_s if config["password"] end + + def report_success(success) + if success + puts '[DONE]'.green + else + puts '[FAILED]'.red + end + end end end |