Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backup job #155

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$service_group = $::gitlab::service_group
$service_manage = $::gitlab::service_manage
$service_user = $::gitlab::service_user
$rake_exec = $::gitlab::rake_exec
$shell = $::gitlab::shell
$sidekiq = $::gitlab::sidekiq
$sidekiq_cluster = $::gitlab::sidekiq_cluster
Expand All @@ -71,6 +72,15 @@
$gitlab_workhorse = $::gitlab::gitlab_workhorse
$user = $::gitlab::user
$web_server = $::gitlab::web_server
$backup_cron_enable = $::gitlab::backup_cron_enable
$backup_cron_minute = $::gitlab::backup_cron_minute
$backup_cron_hour = $::gitlab::backup_cron_hour
if empty($::gitlab::backup_cron_hour) {
$backup_cron_skips = ''
} else {
$_backup_cron_skips = join($::gitlab::backup_cron_skips, ',')
$backup_cron_skips = "SKIP:${_backup_cron_skips}"
}

# replicate $nginx to $mattermost_nginx if $mattermost_nginx_eq_nginx true
if $mattermost_nginx_eq_nginx {
Expand Down Expand Up @@ -144,7 +154,7 @@
if is_hash($postgresql) {
unless $postgresql[enable] {
exec { 'gitlab_setup':
command => '/bin/echo yes | /usr/bin/gitlab-rake gitlab:setup',
command => "/bin/echo yes | ${rake_exec} gitlab:setup",
refreshonly => true,
timeout => 1800,
require => Exec['gitlab_reconfigure'],
Expand All @@ -170,4 +180,12 @@
mode => '0644',
}
}

if $backup_cron_enable {
cron {'gitlab backup':
command => "${rake_exec} gitlab:backup:create CRON=1 ${backup_cron_skips}",
hour => $backup_cron_hour,
minute => $backup_cron_minute,
}
}
}
34 changes: 33 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
# Default: true
# The gitlab service has this commands available.
#
# [*rake_exec*]
# Default: '/usr/bin/gitlab-rake'
# The gitlab-rake executable path.
# You should not need to change this path.
#
# [*edition*]
# Default: ce
# Gitlab edition to install. ce or ee.
Expand Down Expand Up @@ -291,6 +296,24 @@
# Default: undef
# Hash of 'high_availability' config parameters.
#
# [*backup_cron_enable*]
# Default: false
# Boolean to enable the daily backup cron job
#
# [*backup_cron_minute*]
# Default: 0
# The minute when to run the daily backup cron job
#
# [*backup_cron_hour*]
# Default: 2
# The hour when to run the daily backup cron job
#
# [*backup_cron_skips*]
# Default: []
# Array of items to skip
# valid values: db, uploads, repositories, builds,
# artifacts, lfs, registry, pages
#
# === Examples
#
# class { 'gitlab':
Expand Down Expand Up @@ -328,6 +351,7 @@
$service_stop = $::gitlab::params::service_stop,
$service_user = $::gitlab::params::service_user,
# gitlab specific
$rake_exec = $::gitlab::params::rake_exec,
$edition = 'ce',
$ci_redis = undef,
$ci_unicorn = undef,
Expand Down Expand Up @@ -387,6 +411,10 @@
$gitlab_workhorse = undef,
$user = undef,
$web_server = undef,
$backup_cron_enable = false,
$backup_cron_minute = 0,
$backup_cron_hour = 2,
$backup_cron_skips = [],
$custom_hooks = {},
) inherits ::gitlab::params {

Expand Down Expand Up @@ -451,6 +479,10 @@
if $web_server { validate_hash($web_server) }
if $high_availability { validate_hash($high_availability) }
if $manage_accounts { validate_hash($manage_accounts) }
validate_bool($backup_cron_enable)
validate_integer($backup_cron_minute,59)
validate_integer($backup_cron_hour,23)
validate_array($backup_cron_skips)
validate_hash($custom_hooks)

class { '::gitlab::install': } ->
Expand All @@ -460,7 +492,7 @@
contain gitlab::install
contain gitlab::config
contain gitlab::service

create_resources(gitlab::custom_hook, $custom_hooks)

}
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
$manage_package_repo = true
$manage_package = true

$rake_exec = '/usr/bin/gitlab-rake'

$service_exec = '/usr/bin/gitlab-ctl'
$service_restart = "${service_exec} restart"
$service_start = "${service_exec} start"
Expand Down