summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-06-10 20:08:23 +0000
committerRobert Speicher <robert@gitlab.com>2016-06-10 20:08:23 +0000
commitff345f8ba11658c679b423e06bbc42b90af158eb (patch)
treec1e4f82d200e5068270c9fc77d49b7f914ae4d76
parentb4e84809e8170a43126507da0bc6a3b94c33804b (diff)
parentf03df228155ae2d8dd779bd1a8e4078698b23c06 (diff)
downloadgitlab-ce-ff345f8ba11658c679b423e06bbc42b90af158eb.tar.gz
Merge branch 'create-backup-dir-for-local' into 'master'
Only create the backup directory if it is local Closes #12710 See merge request !4551
-rw-r--r--lib/backup/manager.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 9dd665441a0..2ff3e3bdfb0 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -38,7 +38,6 @@ module Backup
end
def upload(tar_file)
- remote_directory = Gitlab.config.backup.upload.remote_directory
$progress.print "Uploading backup archive to remote storage #{remote_directory} ... "
connection_settings = Gitlab.config.backup.upload.connection
@@ -47,8 +46,7 @@ module Backup
return
end
- connection = ::Fog::Storage.new(connection_settings)
- directory = connection.directories.create(key: remote_directory)
+ directory = connect_to_remote_directory(connection_settings)
if directory.files.create(key: tar_file, body: File.open(tar_file), public: false,
multipart_chunk_size: Gitlab.config.backup.upload.multipart_chunk_size,
@@ -155,6 +153,23 @@ module Backup
private
+ def connect_to_remote_directory(connection_settings)
+ connection = ::Fog::Storage.new(connection_settings)
+
+ # We only attempt to create the directory for local backups. For AWS
+ # and other cloud providers, we cannot guarantee the user will have
+ # permission to create the bucket.
+ if connection.service == ::Fog::Storage::Local
+ connection.directories.create(key: remote_directory)
+ else
+ connection.directories.get(remote_directory)
+ end
+ end
+
+ def remote_directory
+ Gitlab.config.backup.upload.remote_directory
+ end
+
def backup_contents
folders_to_backup + archives_to_backup + ["backup_information.yml"]
end