-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SVCPLAN-5526: Convert backup class to use parameters to can be overwr…
…itten
- Loading branch information
Showing
3 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
# @summary Configure GitLab backups | ||
# | ||
# @param paths | ||
# List of paths (locations to files or directories) to be backed up. | ||
# | ||
# @param prehook_commands | ||
# List of commands to run before the paths are backed up. | ||
# | ||
# @param posthook_commands | ||
# List of commands to run after the paths are backed up. | ||
# | ||
# @example | ||
# include profile_gitlab::backup | ||
class profile_gitlab::backup { | ||
class profile_gitlab::backup ( | ||
Array[String] $paths, | ||
Array[String] $prehook_commands, | ||
Array[String] $posthook_commands, | ||
) { | ||
if ( lookup('profile_backup::client::enabled') ) { | ||
include profile_backup::client | ||
|
||
profile_backup::client::add_job { 'profile_gitlab': | ||
paths => [ | ||
'/etc/gitlab', | ||
'/var/opt/gitlab/backups', | ||
], | ||
prehook_commands => [ | ||
'/opt/gitlab/bin/gitlab-backup create CRON=1', | ||
], | ||
posthook_commands => [ | ||
"find /etc/gitlab/config_backup \\( -name '*.tar' \\) -mtime +30 -type f -exec rm -rf {} \\;", | ||
"find /var/opt/gitlab/backups \\( -name '*.tar' \\) -mtime +2 -type f -exec rm -rf {} \\;", | ||
], | ||
} | ||
|
||
# REMOVE OLD BACKUP CRONS FROM <= v0.1.1 OF THIS MODULE | ||
# THIS LOGIC CAN BE REMOVED IN FUTURE VERSIONS OF THIS MODULE | ||
cron { 'GITLAB DAILY BACKUPS': | ||
ensure => 'absent', | ||
} | ||
cron { 'GITLAB CLEANUP BACKUPS': | ||
ensure => 'absent', | ||
paths => $paths, | ||
prehook_commands => $prehook_commands, | ||
posthook_commands => $posthook_commands, | ||
} | ||
} | ||
} |