Is there any configuration in gitlab where i can automate the backup daily/weekly?
I have done this creating a script and cron job for my gitlab-ce installation. I can share it if you like. When I get on my laptop tomorrow morning I will post it.
So I do my backup like this:
#!/bin/bash
#
# Script to backup gitlab-ce
# Variables
PKGNAME=gitlab
PKGVER=`dpkg -l | grep -i gitlab | awk '{print $3}'`
GITLABCONFDIR=/etc/gitlab
GITLABBACKUPS=/var/opt/gitlab/backups
BACKUPDIR=/backups/gitlab
BACKUPDATE=`date '+%F'`
# Cleanup old backups and wait a minute
find $BACKUPDIR -type f -ctime +2 -exec rm -f {} \;
sleep 60
# Remove existing gitlab backups
rm -f $GITLABBACKUPS/*
# Backup Gitlab
sudo -u git -H gitlab-rake gitlab:backup:create
tar cvjpf $BACKUPDIR/$PKGNAME-$PKGVER-data-$BACKUPDATE.tar.bz2 $GITLABBACKUPS/*.tar
# Backup Gitlab config
tar cvjpf $BACKUPDIR/$PKGNAME-$PKGVER-config-$BACKUPDATE.tar.bz2 $GITLABCONFDIR
the variables at the top allow me to dynamically alter the filenames when a new version of gitlab is installed/upgraded, as you can see from below:
root@repo:~/scripts# ls /backups/gitlab/
gitlab-13.4.1-ce.0-config-2020-09-28.tar.bz2 gitlab-13.4.1-ce.0-data-2020-09-28.tar.bz2
gitlab-13.4.1-ce.0-config-2020-09-29.tar.bz2 gitlab-13.4.1-ce.0-data-2020-09-29.tar.bz2
gitlab-13.4.1-ce.0-config-2020-09-30.tar.bz2 gitlab-13.4.1-ce.0-data-2020-09-30.tar.bz2
gitlab-13.4.1-ce.0-config-2020-10-01.tar.bz2 gitlab-13.4.1-ce.0-data-2020-10-01.tar.bz2
the backup takes the config so /etc/gitlab and the database backups. If you want to add to this the repo data, then you need to add /var/opt/gitlab/git-data to the script. I actually do that however using a Synology NAS and the backup application on there takes the filesystem as well as the /backups directory so that I have it away from the server in the event of failure.
Hope it helps!
Ian
Hello sir, I hope you’re doing well. Have you made any updates to the this GitLab backup script? If so, could you please share the details with us? Your cooperation would be greatly appreciated.
No I haven’t, feel free to use and adapt it to your requirements.