Puppet Class: gitlab::backup

Defined in:
modules/gitlab/manifests/backup.pp

Summary

manage backup timers

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • full_ensure (Wmflib::Ensure) (defaults to: 'present')
  • partial_ensure (Wmflib::Ensure) (defaults to: 'present')
  • config_ensure (Wmflib::Ensure) (defaults to: 'present')
  • rsyncable_gzip (String) (defaults to: 'yes')
  • max_concurrency (Integer[1]) (defaults to: 4)
  • max_storage_concurrency (Integer[1]) (defaults to: 2)
  • backup_keep_time (Integer[1]) (defaults to: 3)
  • backup_dir_data (Stdlib::Unixpath) (defaults to: '/srv/gitlab-backup')
  • backup_dir_config (Stdlib::Unixpath) (defaults to: '/etc/gitlab/config_backup')
  • full_backup_interval (Systemd::Timer::Schedule) (defaults to: {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'})
  • config_backup_interval (Systemd::Timer::Schedule) (defaults to: {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'})
  • partial_backup_interval (Systemd::Timer::Schedule) (defaults to: {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'})


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'modules/gitlab/manifests/backup.pp', line 3

class gitlab::backup (
    Wmflib::Ensure           $ensure                  = 'present',
    Wmflib::Ensure           $full_ensure             = 'present',
    Wmflib::Ensure           $partial_ensure          = 'present',
    Wmflib::Ensure           $config_ensure           = 'present',
    String                   $rsyncable_gzip          = 'yes',
    Integer[1]               $max_concurrency         = 4,
    Integer[1]               $max_storage_concurrency = 2,
    Integer[1]               $backup_keep_time        = 3,
    Stdlib::Unixpath         $backup_dir_data         = '/srv/gitlab-backup',
    Stdlib::Unixpath         $backup_dir_config       = '/etc/gitlab/config_backup',
    Systemd::Timer::Schedule $full_backup_interval    = {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'},
    Systemd::Timer::Schedule $config_backup_interval  = {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'},
    Systemd::Timer::Schedule $partial_backup_interval = {'start' => 'OnCalendar', 'interval' => '*-*-* 00:00:00'},
) {

    # install backup config. This is separate to the script to avoid templating executables, T254480
    file { "${backup_dir_data}/gitlab-backup-config.sh":
        ensure  => file,
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
        content => template('gitlab/gitlab-backup-config.sh.erb'), # TODO: remove, T254480
    }

    file { "${backup_dir_data}/gitlab-backup-restore-common.sh":
        ensure => file,
        mode   => '0644',
        owner  => 'root',
        group  => 'root',
        source => 'puppet:///modules/gitlab/gitlab-backup-restore-common.sh',
    }

    file { "${backup_dir_data}/gitlab-backup.sh":
        ensure => file,
        mode   => '0744',
        owner  => 'root',
        group  => 'root',
        source => 'puppet:///modules/gitlab/gitlab-backup.sh',
    }

    # systemd timer for full backups
    systemd::timer::job { 'full-backup':
        ensure      => $full_ensure,
        user        => 'root',
        description => 'GitLab full data backup',
        command     => "${backup_dir_data}/gitlab-backup.sh full",
        interval    => $full_backup_interval,
    }

    # systemd timer for partial backups
    systemd::timer::job { 'partial-backup':
        ensure      => $partial_ensure,
        user        => 'root',
        description => 'GitLab partial data backup',
        command     => "${backup_dir_data}/gitlab-backup.sh partial",
        interval    => $partial_backup_interval,
    }

    # systemd timer for config backups
    systemd::timer::job { 'config-backup':
        ensure      => $config_ensure,
        user        => 'root',
        description => 'GitLab config backup',
        command     => "${backup_dir_data}/gitlab-backup.sh config",
        interval    => $config_backup_interval,
    }

    # make sure git user can access backup folders
    # create folder for backups
    file { $backup_dir_data:
        ensure => directory,
        owner  => 'git',
        group  => 'root',
        mode   => '0600',
    }

}