summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Van Espen <fes@escaux.com>2019-03-07 09:38:14 +0100
committerFrederic Van Espen <fes@escaux.com>2019-03-07 09:38:14 +0100
commit935b69838488f13586541114e0293e5ef6d79f43 (patch)
treec0416a746cd9cf32a95aea4d1d64b9c77a463c06
parent3bb3f7ddd073e67fafbc210d0e18c76a87b96dcb (diff)
downloadgitlab-ce-935b69838488f13586541114e0293e5ef6d79f43.tar.gz
introduce optional rsyncable flag
-rw-r--r--doc/raketasks/backup_restore.md7
-rw-r--r--lib/backup/database.rb3
-rw-r--r--lib/backup/files.rb4
-rw-r--r--lib/backup/helper.rb9
4 files changed, 20 insertions, 3 deletions
diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md
index 4238685b54f..22a67e3ed01 100644
--- a/doc/raketasks/backup_restore.md
+++ b/doc/raketasks/backup_restore.md
@@ -205,6 +205,13 @@ sudo gitlab-rake gitlab:backup:create BACKUP=dump
The resulting file will then be `dump_gitlab_backup.tar`. This is useful for systems that make use of rsync and incremental backups, and will result in considerably faster transfer speeds.
+### Rsyncable
+
+To make sure the generated archive is intelligently transferable by rsync, the `GZIP_RSYNCABLE=yes` option can be set. This will set the `--rsyncable` option to `gzip`. This is only useful in combination with setting [the Backup filename option](#backup-filename). Note that this option in `gzip` is not guaranteed to be available on all distributions.
+
+```sh
+sudo gitlab-rake gitlab:backup:create BACKUP=dump GZIP_RSYNCABLE=yes
+```
### Excluding specific directories from the backup
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index 8baca500546..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 --rsyncable -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 998fa5a1a92..427c65e2d91 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 --rsyncable -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 --rsyncable -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..9e10822f56c 100644
--- a/lib/backup/helper.rb
+++ b/lib/backup/helper.rb
@@ -29,5 +29,14 @@ 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