diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-06 14:43:19 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-06 14:43:19 +0200 |
commit | d3734fbd89c069d35856b440f12109af8a7ef9c9 (patch) | |
tree | 1d9489c8291a577b0d0d6955cbd9c7a7c9f274e4 /lib/backup/builds.rb | |
parent | a2af080a06b3439d37258d88ac6d6db9ef51c6a5 (diff) | |
download | gitlab-ce-d3734fbd89c069d35856b440f12109af8a7ef9c9.tar.gz |
Use tar for intermediate backup storage
During the backup we create an intermediate copy of two directories:
builds and uploads. Instead of creating many small files with 'cp
-r', we now use tar (and fast gzip) to create single intermediate
files. This saves on disk IO and disk space while creating a backup.
Diffstat (limited to 'lib/backup/builds.rb')
-rw-r--r-- | lib/backup/builds.rb | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/backup/builds.rb b/lib/backup/builds.rb index 6f56f680bb9..d269f8e260c 100644 --- a/lib/backup/builds.rb +++ b/lib/backup/builds.rb @@ -1,34 +1,7 @@ module Backup - class Builds - attr_reader :app_builds_dir, :backup_builds_dir, :backup_dir - + class Builds < Files def initialize - @app_builds_dir = Settings.gitlab_ci.builds_path - @backup_dir = Gitlab.config.backup.path - @backup_builds_dir = File.join(Gitlab.config.backup.path, 'builds') - end - - # Copy builds from builds directory to backup/builds - def dump - FileUtils.rm_rf(backup_builds_dir) - # Ensure the parent dir of backup_builds_dir exists - FileUtils.mkdir_p(Gitlab.config.backup.path) - # Fail if somebody raced to create backup_builds_dir before us - FileUtils.mkdir(backup_builds_dir, mode: 0700) - FileUtils.cp_r(app_builds_dir, backup_dir) - end - - def restore - backup_existing_builds_dir - - FileUtils.cp_r(backup_builds_dir, app_builds_dir) - end - - def backup_existing_builds_dir - timestamped_builds_path = File.join(app_builds_dir, '..', "builds.#{Time.now.to_i}") - if File.exists?(app_builds_dir) - FileUtils.mv(app_builds_dir, File.expand_path(timestamped_builds_path)) - end + super(Settings.gitlab_ci.builds_path) end end end |