summaryrefslogtreecommitdiff
path: root/lib/backup/database.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backup/database.rb')
-rw-r--r--lib/backup/database.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index 5e6828de597..1608f7ad02d 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -2,9 +2,11 @@ require 'yaml'
module Backup
class Database
+ attr_reader :progress
attr_reader :config, :db_file_name
- def initialize
+ def initialize(progress)
+ @progress = progress
@config = YAML.load_file(File.join(Rails.root, 'config', 'database.yml'))[Rails.env]
@db_file_name = File.join(Gitlab.config.backup.path, 'db', 'database.sql.gz')
end
@@ -19,12 +21,12 @@ module Backup
dump_pid =
case config["adapter"]
when /^mysql/ then
- $progress.print "Dumping MySQL database #{config['database']} ... "
+ progress.print "Dumping MySQL database #{config['database']} ... "
# Workaround warnings from MySQL 5.6 about passwords on cmd line
ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
spawn('mysqldump', *mysql_args, config['database'], out: compress_wr)
when "postgresql" then
- $progress.print "Dumping PostgreSQL database #{config['database']} ... "
+ progress.print "Dumping PostgreSQL database #{config['database']} ... "
pg_env
pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
if Gitlab.config.backup.pg_schema
@@ -53,12 +55,12 @@ module Backup
restore_pid =
case config["adapter"]
when /^mysql/ then
- $progress.print "Restoring MySQL database #{config['database']} ... "
+ progress.print "Restoring MySQL database #{config['database']} ... "
# Workaround warnings from MySQL 5.6 about passwords on cmd line
ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
spawn('mysql', *mysql_args, config['database'], in: decompress_rd)
when "postgresql" then
- $progress.print "Restoring PostgreSQL database #{config['database']} ... "
+ progress.print "Restoring PostgreSQL database #{config['database']} ... "
pg_env
spawn('psql', config['database'], in: decompress_rd)
end
@@ -111,9 +113,9 @@ module Backup
def report_success(success)
if success
- $progress.puts '[DONE]'.color(:green)
+ progress.puts '[DONE]'.color(:green)
else
- $progress.puts '[FAILED]'.color(:red)
+ progress.puts '[FAILED]'.color(:red)
end
end
end