Gitlab backup and restore operations

  Reference: https://www.cnblogs.com/kevingrace/p/7821529.html

  

  1. Set up backup and backup path

  /etc/gitlab/gitlab.rb

gitlab_rails['manage_backup_path'] = true #Enable backup
gitlab_rails['backup_path'] = "/data/gitlab/backups" #Set the backup path
gitlab_rails['backup_archive_permissions'] = 0644 #Permissions for backup files
gitlab_rails['backup_keep_time'] = 604800 #Backup retention days, the unit is seconds, which is 7 days

  Create a backup path and set permissions

mkdir -p /data/gitlab/backups
chown -R git.git /data/gitlab/backups
chmod -R 777 /data/gitlab/backups

  Settings take effect

gitlab-ctl reconfigure

  

  Second, manually use the command to backup

gitlab-rake gitlab:backup:create

   After the execution is completed, you can see the backup file under the backup path.

  Set footsteps to backup regularly

  gitlab_backup.sh

#!/bin/bash
/usr/bin/gitlab-rake gitlab:backup:create CRON=1

  PS: The effect of the environment variable CRON=1 is to suppress all progress output of the backup script if no errors occur

  crontab -e

0 0,6,12,18 * * * /bin/bash -x /data/gitlab/backups/gitlab_backup.sh > /dev/null 2>&1

  

  Three, recovery operation

  stop database connection

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

  View status

gitlab-ctl status

  Recovery (enter yes if you need to enter)

  Before recovery, you can delete a test library such as test and then check whether it is recovered after recovery

gitlab-rake gitlab:backup:restore backup=1525801521_gitlab_backup.tar

  start gitlab again

gitlab-ctl start

 

  PS: In addition: Gitlab migration is the same as recovery, but requires two GitLab version numbers to be consistent

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326032534&siteId=291194637