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
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-07 20:20:05 +0300
committerStan Hu <stanhu@gmail.com>2019-03-07 20:20:05 +0300
commit5211386293cdd95fd6161019716301f806749137 (patch)
tree29448b867d1d7d89a5c32ee1543d660d4dd7cc8d /lib
parentfc942cd2f98a5991580ce686932fd00da019780c (diff)
parenta2a0a9215b71f188c17b2fa08034092e61642c84 (diff)
Merge branch 'incremental-backups' into 'master'
Incremental backups See merge request gitlab-org/gitlab-ce!24035
Diffstat (limited to 'lib')
-rw-r--r--lib/backup/database.rb3
-rw-r--r--lib/backup/files.rb4
-rw-r--r--lib/backup/helper.rb8
-rw-r--r--lib/backup/manager.rb6
4 files changed, 17 insertions, 4 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index e6bf3d1856f..cd8e29d14d3 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -4,6 +4,7 @@ require 'yaml'
module Backup
class Database
+ include Backup::Helper
attr_reader :progress
attr_reader :config, :db_file_name
@@ -17,7 +18,7 @@ module Backup
FileUtils.mkdir_p(File.dirname(db_file_name))
FileUtils.rm_f(db_file_name)
compress_rd, compress_wr = IO.pipe
- compress_pid = spawn(*%w(gzip -1 -c), in: compress_rd, out: [db_file_name, 'w', 0600])
+ compress_pid = spawn(gzip_cmd, in: compress_rd, out: [db_file_name, 'w', 0600])
compress_rd.close
dump_pid =
diff --git a/lib/backup/files.rb b/lib/backup/files.rb
index 2bac84846c5..098f2da6d88 100644
--- a/lib/backup/files.rb
+++ b/lib/backup/files.rb
@@ -31,10 +31,10 @@ module Backup
raise Backup::Error, 'Backup failed'
end
- run_pipeline!([%W(#{tar} --exclude=lost+found -C #{@backup_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
+ run_pipeline!([%W(#{tar} --exclude=lost+found -C #{@backup_files_dir} -cf - .), gzip_cmd], out: [backup_tarball, 'w', 0600])
FileUtils.rm_rf(@backup_files_dir)
else
- run_pipeline!([%W(#{tar} --exclude=lost+found -C #{app_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
+ run_pipeline!([%W(#{tar} --exclude=lost+found -C #{app_files_dir} -cf - .), gzip_cmd], out: [backup_tarball, 'w', 0600])
end
end
diff --git a/lib/backup/helper.rb b/lib/backup/helper.rb
index 22f00aef569..2c2e35add0e 100644
--- a/lib/backup/helper.rb
+++ b/lib/backup/helper.rb
@@ -29,5 +29,13 @@ module Backup
EOS
raise message
end
+
+ def gzip_cmd
+ @gzip_cmd ||= if ENV['GZIP_RSYNCABLE'] == 'yes'
+ "gzip --rsyncable -c -1"
+ else
+ "gzip -c -1"
+ end
+ end
end
end
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 06b0338b1ed..aeaf61cda39 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -235,7 +235,11 @@ module Backup
end
def tar_file
- @tar_file ||= "#{backup_information[:backup_created_at].strftime('%s_%Y_%m_%d_')}#{backup_information[:gitlab_version]}#{FILE_NAME_SUFFIX}"
+ @tar_file ||= if ENV['BACKUP']
+ ENV['BACKUP'] + "#{FILE_NAME_SUFFIX}"
+ else
+ "#{backup_information[:backup_created_at].strftime('%s_%Y_%m_%d_')}#{backup_information[:gitlab_version]}#{FILE_NAME_SUFFIX}"
+ end
end
def backup_information