Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/manager.rb17
-rw-r--r--lib/backup/repositories.rb20
2 files changed, 30 insertions, 7 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index b5e1634004a..d56f852b23c 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -12,7 +12,8 @@ module Backup
LIST_ENVS = {
skipped: 'SKIP',
repositories_storages: 'REPOSITORIES_STORAGES',
- repositories_paths: 'REPOSITORIES_PATHS'
+ repositories_paths: 'REPOSITORIES_PATHS',
+ skip_repositories_paths: 'SKIP_REPOSITORIES_PATHS'
}.freeze
YAML_PERMITTED_CLASSES = [
@@ -176,6 +177,11 @@ module Backup
human_name: _('packages'),
destination_path: 'packages.tar.gz',
task: build_files_task(Settings.packages.storage_path, excludes: ['tmp'])
+ ),
+ 'ci_secure_files' => TaskDefinition.new(
+ human_name: _('ci secure files'),
+ destination_path: 'ci_secure_files.tar.gz',
+ task: build_files_task(Settings.ci_secure_files.storage_path, excludes: ['tmp'])
)
}.freeze
end
@@ -194,7 +200,8 @@ module Backup
Repositories.new(progress,
strategy: strategy,
storages: list_env(:repositories_storages),
- paths: list_env(:repositories_paths)
+ paths: list_env(:repositories_paths),
+ skip_paths: list_env(:skip_repositories_paths)
)
end
@@ -278,7 +285,8 @@ module Backup
installation_type: Gitlab::INSTALLATION_TYPE,
skipped: ENV['SKIP'],
repositories_storages: ENV['REPOSITORIES_STORAGES'],
- repositories_paths: ENV['REPOSITORIES_PATHS']
+ repositories_paths: ENV['REPOSITORIES_PATHS'],
+ skip_repositories_paths: ENV['SKIP_REPOSITORIES_PATHS']
}
end
@@ -292,7 +300,8 @@ module Backup
installation_type: Gitlab::INSTALLATION_TYPE,
skipped: list_env(:skipped).join(','),
repositories_storages: list_env(:repositories_storages).join(','),
- repositories_paths: list_env(:repositories_paths).join(',')
+ repositories_paths: list_env(:repositories_paths).join(','),
+ skip_repositories_paths: list_env(:skip_repositories_paths).join(',')
)
end
diff --git a/lib/backup/repositories.rb b/lib/backup/repositories.rb
index 218df3fcb6c..56726665d14 100644
--- a/lib/backup/repositories.rb
+++ b/lib/backup/repositories.rb
@@ -10,13 +10,15 @@ module Backup
# @param [IO] progress IO interface to output progress
# @param [Object] :strategy Fetches backups from gitaly
# @param [Array<String>] :storages Filter by specified storage names. Empty means all storages.
- # @param [Array<String>] :paths Filter by specified project paths. Empty means all projects, groups and snippets.
- def initialize(progress, strategy:, storages: [], paths: [])
+ # @param [Array<String>] :paths Filter by specified project paths. Empty means all projects, groups, and snippets.
+ # @param [Array<String>] :skip_paths Skip specified project paths. Empty means all projects, groups, and snippets.
+ def initialize(progress, strategy:, storages: [], paths: [], skip_paths: [])
super(progress)
@strategy = strategy
@storages = storages
@paths = paths
+ @skip_paths = skip_paths
end
override :dump
@@ -42,7 +44,7 @@ module Backup
private
- attr_reader :strategy, :storages, :paths
+ attr_reader :strategy, :storages, :paths, :skip_paths
def remove_all_repositories
return if paths.present?
@@ -84,6 +86,7 @@ module Backup
)
end
+ scope = scope.and(skipped_path_relation) if skip_paths.any?
scope
end
@@ -98,9 +101,20 @@ module Backup
)
end
+ if skip_paths.any?
+ scope = scope.where(project: skipped_path_relation)
+ scope = scope.or(Snippet.where(project: nil)) if !paths.any? && !storages.any?
+ end
+
scope
end
+ def skipped_path_relation
+ Project.where.not(id: Project.where_full_path_in(skip_paths).or(
+ Project.where(namespace_id: Namespace.where_full_path_in(skip_paths).self_and_descendants)
+ ))
+ end
+
def restore_object_pools
PoolRepository.includes(:source_project).find_each do |pool|
progress.puts " - Object pool #{pool.disk_path}..."