Skip to content

deviant310/gitlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab VCS + restore from backup + saving backup file hook

IMPORTANT: Your gitlab environment will have access to your host environment via ssh and will try to push changes into this repo. So this repo shouldn't have any collaborators. After cloning this repo CHANGE remote origin on yours which you have access, so your host can push to your remote. Make this repo private because it will keep your credentials.

Installation with Docker

  1. Install OpenSSH server to your host machine

    sudo apt install openssh-server

    Allow authentication by public key. Uncomment line in your /etc/ssh/sshd_config:

    PubkeyAuthentication yes
    

    Restart your ssh service

    sudo service ssh restart
  2. Create .env file from .env.example, replace values if necessary.

    cp .env.example .env

    At least you must change APP_USER value and set your host username

  3. Run the container

    docker-compose up -d

NOTE: Replace gitlab-web-1 to your container name, if necessary

  1. Generate ssh keys inside the container

    docker exec -it --user git gitlab-web-1 ssh-keygen -q -t rsa -N '' -f /var/opt/gitlab/.ssh/id_rsa -C root@gitlab_web
  2. Add generated public key to authorized_keys on your host

    docker exec -it gitlab-web-1 cat /var/opt/gitlab/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
  3. Reconfigure gitlab and restart your container

    docker exec -it gitlab-web-1 gitlab-ctl reconfigure
    docker restart gitlab-web-1

Restore from backup

IMPORTANT: Actual for second and further deployments. Beware of using existing backups at first deployment due to gitlab builds versions conflicts. Just skip this paragraph at first deployment. In further deployments you will find your backups and configs in appropriate folders of this repo: backups and config.

To restore from existing backup run the following command:

NOTE: Replace gitlab-web-1 to your container name, if necessary

CONTAINER=gitlab-web-1 ./restore.sh

Back up

File hook hooks/backup.sh will generate backup file on every event triggered in GitLab. Then it will be sent to VCS of this repository. If you want to do it manually, run the following command:

NOTE: Replace gitlab-web-1 to your container name, if necessary

docker exec -it --user git gitlab-web-1 /opt/gitlab/embedded/service/gitlab-rails/file_hooks/backup.sh

or validate your file hooks (will execute all file hooks)

docker exec -it gitlab-web-1 gitlab-rake file_hooks:validate

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages