Commit 935b6983 authored by Frederic Van Espen's avatar Frederic Van Espen

introduce optional rsyncable flag

parent 3bb3f7dd
...@@ -205,6 +205,13 @@ sudo gitlab-rake gitlab:backup:create BACKUP=dump ...@@ -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. 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 ### Excluding specific directories from the backup
......
...@@ -4,6 +4,7 @@ require 'yaml' ...@@ -4,6 +4,7 @@ require 'yaml'
module Backup module Backup
class Database class Database
include Backup::Helper
attr_reader :progress attr_reader :progress
attr_reader :config, :db_file_name attr_reader :config, :db_file_name
...@@ -17,7 +18,7 @@ module Backup ...@@ -17,7 +18,7 @@ module Backup
FileUtils.mkdir_p(File.dirname(db_file_name)) FileUtils.mkdir_p(File.dirname(db_file_name))
FileUtils.rm_f(db_file_name) FileUtils.rm_f(db_file_name)
compress_rd, compress_wr = IO.pipe 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 compress_rd.close
dump_pid = dump_pid =
......
...@@ -31,10 +31,10 @@ module Backup ...@@ -31,10 +31,10 @@ module Backup
raise Backup::Error, 'Backup failed' raise Backup::Error, 'Backup failed'
end 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) FileUtils.rm_rf(@backup_files_dir)
else 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
end end
......
...@@ -29,5 +29,14 @@ module Backup ...@@ -29,5 +29,14 @@ module Backup
EOS EOS
raise message raise message
end end
def gzip_cmd
@gzip_cmd ||= if ENV['GZIP_RSYNCABLE'] = 'yes'
"gzip --rsyncable -c -1"
else
"gzip -c -1"
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