Scripts to backup & restore your Gitlab docker installation For Gitlab docker installation see this link
Run gl_backup.sh as root in order to create a backup
Before you begin, make sure you check the following:
openssl,zip,rsyncneed to be installed. If not, use the package manager of your distro to install them- Some variables need to be set up first.
Every line starting with
TODOneeds your input. Lines withOPTIONare optionally - Consider reading the documentation at Gitlab first. Check this and this as well
The standard backup location is /srv/gitlab/data/backups. You can choose to move your backups to a remote location. If you want this, uncomment the last lines and make sure you enter a remote location (eg /mnt/samba) for the variable rsync_loc.
After the backup has been succesfully created, rsync will be used to move the files to your remote location.
The backup is saved in a directory with the date eg YYYYMMDD with the following names:
YYMMDD_HH_MM_gitlab_backup.tar: the main backup of your gitlab installation (repositories, db...)YYMMDD_HH_MM_gitlab_config.zip: the configuration of your gitlab installation, protected with the password saved in/home/glYYMMDD_HH_MM_webserver.zip: optionally the configuration for your webserver (eg if you use one for reverse proxy)
The configuration data contains the encryption keys to protect the following sensitive data in the SQL database:
- 2FA user secrets
- CI Secure variables
As such it is advised to not store the config backup next to your data backup. I've opt to store them in the same place, but securing the config data with a strong password. This is generated upon the first backup and can be found under /home/gl. Make sure you take a note of this password.
You can schedule a backup job by setting a cronjob for the root user eg:
0 3 * * * /path/to/gl_backup.sh
Run gl_restore.sh as root in order to initiate restore.
(WIP)