summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-09-29 15:02:39 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-09-29 15:03:08 +0200
commite1f6fa6f18afa8461cd82a56250222c2972c7785 (patch)
tree0ab90fe685c4054f8752dd7c5b196a39b9fa8d42 /lib/backup
parent0e8e9e5d77478294288d34474e580916418ddd91 (diff)
downloadgitlab-ce-e1f6fa6f18afa8461cd82a56250222c2972c7785.tar.gz
Add backup upload support to the rake task
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/manager.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 28e323fe30d..908f10a4138 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -9,6 +9,7 @@ module Backup
s[:backup_created_at] = Time.now
s[:gitlab_version] = Gitlab::VERSION
s[:tar_version] = tar_version
+ tar_file = "#{s[:backup_created_at].to_i}_gitlab_backup.tar"
Dir.chdir(Gitlab.config.backup.path)
@@ -17,8 +18,29 @@ module Backup
end
# create archive
- print "Creating backup archive: #{s[:backup_created_at].to_i}_gitlab_backup.tar ... "
- if Kernel.system('tar', '-cf', "#{s[:backup_created_at].to_i}_gitlab_backup.tar", *BACKUP_CONTENTS)
+ print "Creating backup archive: #{tar_file} ... "
+ if Kernel.system('tar', '-cf', tar_file, *BACKUP_CONTENTS)
+ puts "done".green
+ else
+ puts "failed".red
+ end
+
+ upload(tar_file)
+ end
+
+ def upload(tar_file)
+ remote_directory = Gitlab.config.backup.upload.remote_directory
+ print "Uploading backup archive to remote storage #{remote_directory} ... "
+
+ connection_settings = Gitlab.config.backup.upload.connection
+ if connection_settings.blank?
+ puts "skipped".yellow
+ return
+ end
+
+ connection = ::Fog::Storage.new(connection_settings)
+ directory = connection.directories.get(remote_directory)
+ if directory.files.create(key: tar_file, body: File.open(tar_file), public: false)
puts "done".green
else
puts "failed".red