Commit 1e72c227 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'skr-backup-log-1' into 'master'

Add backup logger class

See merge request gitlab-org/gitlab!63832
parents d284109d 820d264e
# frozen_string_literal: true
module Gitlab
class BackupLogger < Gitlab::JsonLogger
def self.file_name_noext
'backup_json'
end
end
end
...@@ -282,6 +282,7 @@ namespace :gitlab do ...@@ -282,6 +282,7 @@ namespace :gitlab do
def puts_time(msg) def puts_time(msg)
progress.puts "#{Time.now} -- #{msg}" progress.puts "#{Time.now} -- #{msg}"
Gitlab::BackupLogger.info(message: "#{Rainbow.uncolor(msg)}")
end end
def progress def progress
......
...@@ -209,6 +209,23 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do ...@@ -209,6 +209,23 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect { run_rake_task("gitlab:backup:#{task}:create") }.to output(/Dumping /).to_stdout_from_any_process expect { run_rake_task("gitlab:backup:#{task}:create") }.to output(/Dumping /).to_stdout_from_any_process
end end
end end
it 'logs the progress to log file' do
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping database ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "[SKIPPED]")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping repositories ...")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping uploads ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping builds ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping artifacts ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping pages ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping lfs objects ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "Dumping container registry images ... ")
expect(Gitlab::BackupLogger).to receive(:info).with(message: "done").exactly(7).times
task_list.each do |task|
run_rake_task("gitlab:backup:#{task}:create")
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment