Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/backup
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/gitaly_backup.rb19
-rw-r--r--lib/backup/manager.rb13
2 files changed, 23 insertions, 9 deletions
diff --git a/lib/backup/gitaly_backup.rb b/lib/backup/gitaly_backup.rb
index c15b0ed6a1b..55fd68fd6e8 100644
--- a/lib/backup/gitaly_backup.rb
+++ b/lib/backup/gitaly_backup.rb
@@ -25,18 +25,21 @@ module Backup
args += ['-parallel', @parallel.to_s] if type == :create && @parallel
args += ['-parallel-storage', @parallel_storage.to_s] if type == :create && @parallel_storage
- @read_io, @write_io = IO.pipe
- @pid = Process.spawn(bin_path, command, '-path', backup_repos_path, *args, in: @read_io, out: @progress)
+ @stdin, stdout, @thread = Open3.popen2(ENV, bin_path, command, '-path', backup_repos_path, *args)
+
+ @out_reader = Thread.new do
+ IO.copy_stream(stdout, @progress)
+ end
end
def wait
return unless started?
- @write_io.close
- Process.wait(@pid)
- status = $?
+ @stdin.close
+ [@thread, @out_reader].each(&:join)
+ status = @thread.value
- @pid = nil
+ @thread = nil
raise Error, "gitaly-backup exit status #{status.exitstatus}" if status.exitstatus != 0
end
@@ -46,7 +49,7 @@ module Backup
repository = repo_type.repository_for(container)
- @write_io.puts({
+ @stdin.puts({
storage_name: repository.storage,
relative_path: repository.relative_path,
gl_project_path: repository.gl_project_path,
@@ -61,7 +64,7 @@ module Backup
private
def started?
- @pid.present?
+ @thread.present?
end
def backup_repos_path
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 522a034a283..52810b0fb35 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -72,6 +72,17 @@ module Backup
end
end
+ def remove_tmp
+ # delete tmp inside backups
+ progress.print "Deleting backups/tmp ... "
+
+ if FileUtils.rm_rf(File.join(backup_path, "tmp"))
+ progress.puts "done".color(:green)
+ else
+ puts "deleting backups/tmp failed".color(:red)
+ end
+ end
+
def remove_old
# delete backups
progress.print "Deleting old backups ... "
@@ -232,7 +243,7 @@ module Backup
end
def folders_to_backup
- FOLDERS_TO_BACKUP.reject { |name| skipped?(name) }
+ FOLDERS_TO_BACKUP.select { |name| !skipped?(name) && Dir.exist?(File.join(backup_path, name)) }
end
def disabled_features