When using the Omnibus package for GitLab, backups created via gitlab-rake gitlab:backup:create
are stored in a specific directory by default. Understanding this location is crucial for disaster recovery scenarios.
The default backup directory for Omnibus installations is:
/var/opt/gitlab/backups/
You can verify this by running:
sudo ls -lh /var/opt/gitlab/backups/
To modify the backup directory, edit the GitLab configuration file:
sudo nano /etc/gitlab/gitlab.rb
Add or modify this line:
gitlab_rails['backup_path'] = "/your/custom/backup/path"
Then reconfigure GitLab:
sudo gitlab-ctl reconfigure
Backup files follow this pattern:
YYYY_MM_DD_HH_MM_SS_gitlab_backup.tar
Example:
2023_12_25_14_30_00_gitlab_backup.tar
Here's a simple bash script to verify backup creation:
#!/bin/bash
BACKUP_DIR="/var/opt/gitlab/backups"
LATEST_BACKUP=$(ls -t "$BACKUP_DIR" | head -n 1)
if [ -z "$LATEST_BACKUP" ]; then
echo "No backups found in $BACKUP_DIR"
exit 1
else
echo "Latest backup: $BACKUP_DIR/$LATEST_BACKUP"
exit 0
fi
- Backup files contain sensitive data - ensure proper permissions (typically 0600)
- The directory must be writable by the git user
- For large installations, consider using a separate partition
After locating your backup, verify its integrity with:
sudo tar -tf /var/opt/gitlab/backups/LATEST_BACKUP.tar | head -n 10
When using the Omnibus package installation of GitLab, the backup files created with gitlab-rake gitlab:backup:create
are stored in a specific default location. Understanding this location is crucial for backup management and disaster recovery scenarios.
By default, Omnibus installations store backups in:
/var/opt/gitlab/backups/
This directory is automatically created during installation with proper permissions for the GitLab user. Each backup file follows the naming convention:
[TIMESTAMP]_gitlab_backup.tar
You can confirm the backup location by checking GitLab's configuration:
sudo gitlab-rake gitlab:env:info | grep "Backup Path"
# Or check the configuration directly:
sudo grep "backup_path" /etc/gitlab/gitlab.rb
To modify the backup directory, edit GitLab's configuration file:
sudo nano /etc/gitlab/gitlab.rb
Add or modify this line:
gitlab_rails['backup_path'] = "/your/custom/backup/path"
Then reconfigure GitLab:
sudo gitlab-ctl reconfigure
Here's a complete workflow for creating and locating a backup:
# Create backup
sudo gitlab-rake gitlab:backup:create
# List available backups
sudo ls -lh /var/opt/gitlab/backups/
# Sample output:
# -rw------- 1 git git 2.5G Mar 15 10:30 1678879800_2023_03_15_15.0.2_gitlab_backup.tar
To automatically manage backup retention, add this to gitlab.rb
:
gitlab_rails['backup_keep_time'] = 604800 # 7 days in seconds
- Backup files contain sensitive data - ensure proper permissions
- The directory requires sufficient disk space
- Consider remote storage for disaster recovery
- Verify backups regularly with restore tests