-
Make backups of following GitLab configurations
/etc/gitlab/*
- Base configurations of GitLab environments
- User data within GitLab system databases
- With
gitlab-rake
, create backups of repository data
- With
-
Pre-requirements
- Before running script, the target directories must be created by user.
- Confirm that the directory would be created
- Modify the paramenters
PATH_TO_DIR_BACKUP_SAVED
andPATH_TO_TARGET_DIR_TO_BACKUP
in the script
- Before running script, the target directories must be created by user.
-
Run the script
bash ./get_daily_gitbk.sh
- It should be better that you execute the script with
crond
so that you could get daily backups.
- It should be better that you execute the script with
Last active
February 29, 2024 05:51
-
-
Save hwakabh/4cf2d5d959ec2aca26990033efe634c3 to your computer and use it in GitHub Desktop.
GitLab backup utilities
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
#!/bin/bash | |
## Before you run the script: | |
## - Make sure the backup directories would have already created | |
## - Change variables below for your environments | |
## examples: | |
## BKDIR=/var/backup/gitlab.bk | |
## DEFDIR=/var/opt/gitlab/backups | |
BKDIR=PATH_TO_DIR_BACKUP_SAVED | |
DEFDIR=PATH_TO_TARGET_DIR_TO_BACKUP | |
# Get GitLab Configurations backups | |
tar cfz ${BKDIR}/$(date "+%s_%Y_%m_%d_etc_gitlab.tar.gz") -C /etc gitlab | |
# Backing up repository data with Rails | |
/opt/gitlab/bin/gitlab-rake gitlab:backup:create | |
# Copy repository data to backup directory | |
cp -rp ${DEFDIR}/* $BKDIR | |
# Lotations | |
find $BKDIR -mtime +2 |xargs rm -rf | |
find $DEFDIR -mtime +2 |xargs rm -rf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment