[gitlab] Backup & Restore





  • Backup Repository, Wiki, and etc.
  • sudo gitlab-rake gitlab:backup:create




  • Restore gitlab from a backup number 164486484 (move backup file under /var/opt/gitlab/backups/ folder)
  • sudo gitlab-rake gitlab:backup:restore BACKUP=164486484




  • Upload backup to local directory
  • Edit '/etc/gitlab/gitlab.rb', find 'backup_upload_connection', change 'local_root''s value with your backup path
    ----------------------------------------------------------------
    gitlab_rails['backup_upload_connection'] = {
      'provider' => 'Local',
      'local_root' => '/mnt/backups'
    }

    # The directory inside the mounted folder to copy backups to
    # Use '.' to store them in the root directory gitlab_rails['backup_upload_remote_directory'] = 'gitlab_backups' ----------------------------------------------------------------
    Don't forget to give access permission for git user
    You need to run gitlab reconfigure to apply new settings sudo gitlab-ctl reconfigure



  • Setup crontab for daily backup
  • sudo crontab -e Add the following two line command into your crontab (Ex. cron will execute gitlab backup every 2:00 A.M, and backup /etc/gitlab every 2:05 A.M) 0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1 5 2 * * * umask 0077; tar -cf /mnt/gitlab/backups/$(date "+etc-gitlab-%s.tar") -C / etc/gitlab *if you get some error message which are related to folder permission, please make sure your backup location are writeable for git user.




  • Restore Configuration File (Move backup file under /etc/gitlab/ folder)
  • sudo tar -xf etc-gitlab-XXXXXXXXXX.tar -C /
  • Reference
  • https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md http://docs.gitlab.com/omnibus/settings/backups.html

    No comments:

    Post a Comment

    Orange - data analysis tool

    Installation pip install orange3 Run orange python -m Orange.canvas