diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-18 14:33:35 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-18 14:33:35 +0000 |
commit | ac571623d88314c89773ecdb484fc1c4ea92de1a (patch) | |
tree | 0cfea06c73e0f1a0217862f636b818fa1da1b3be | |
parent | 8b05abe816b0c681ac218096b294311dd04fde8b (diff) | |
parent | d7242054bafc49d66b0102f12706ac71a9e5d04c (diff) | |
download | gitlab-ce-ac571623d88314c89773ecdb484fc1c4ea92de1a.tar.gz |
Merge branch 'pg_dump_schema' into 'master'
Add pg_schema to backup config
https://dev.gitlab.org/gitlab/gitlabhq/issues/2489
See merge request !1345
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | config/gitlab.yml.example | 1 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 1 | ||||
-rw-r--r-- | lib/backup/database.rb | 8 |
4 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 811089bbc61..7a54700af04 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -54,6 +54,7 @@ v 8.0.0 (unreleased) - Sort users autocomplete lists by user (Allister Antosik) - Webhook for issue now contains repository field (Jungkook Park) - Add ability to add custom text to the help page (Jeroen van Baarsen) + - Add pg_schema to backup config v 7.14.3 - No changes diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 0005d44e0f2..eada70faebc 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -306,6 +306,7 @@ production: &base path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) # archive_permissions: 0640 # Permissions for the resulting backup.tar file (default: 0600) # keep_time: 604800 # default: 0 (forever) (in seconds) + # pg_schema: public # default: nil, it means that all schemas will be backed up # upload: # # Fog storage connection settings, see http://fog.io/storage/ . # connection: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 274e3d409fb..ddc9bbf5dfd 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -220,6 +220,7 @@ Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_s # Settings['backup'] ||= Settingslogic.new({}) Settings.backup['keep_time'] ||= 0 +Settings.backup['pg_schema'] = nil Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) Settings.backup['archive_permissions'] ||= 0600 Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil }) diff --git a/lib/backup/database.rb b/lib/backup/database.rb index ce75476a09b..959ac4b7868 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -25,8 +25,12 @@ module Backup when "postgresql" then $progress.print "Dumping PostgreSQL database #{config['database']} ... " pg_env - # Pass '--clean' to include 'DROP TABLE' statements in the DB dump. - system('pg_dump', '--clean', config['database'], out: db_file_name) + pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump. + if Gitlab.config.backup.pg_schema + pgsql_args << "-n" + pgsql_args << Gitlab.config.backup.pg_schema + end + system('pg_dump', *pgsql_args, config['database'], out: db_file_name) end report_success(success) abort 'Backup failed' unless success |