- Terraform
- AWS CLI
$ git clone https://github.com/boiyaa/gitlab-ecs-terraform.git
$ cd gitlab-ecs-terraform
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa): devtools-key
$ export AWS_ACCESS_KEY_ID=your key
$ export AWS_SECRET_ACCESS_KEY=your secret
$ export AWS_DEFAULT_REGION=us-east-1
$ terraform init
$ terraform plan --out terraform.tfplan
$ terraform apply terraform.tfplan
Get runner registering command and copy it
$ terraform output gitlab_runner_register
Start bastion instance and log in
$ aws ec2 start-instances --instance-ids `terraform output bastion_id`
$ ssh -i devtools-key ec2-user@`terraform output bastion_ip`
Run the runner registering command and log out
$ docker run ...
$ exit
Stop bastion instance
$ aws ec2 stop-instances --instance-ids `terraform output bastion_id`
$ terraform output bastion_ip
$ terraform output bastion_id
$ aws ec2 describe-instance-status --instance-id `terraform output bastion_id` --query "InstanceStatuses[].InstanceState.Name" --output text
$ aws ec2 describe-instances --filters "Name=tag:Name,Values=devtools-instance-ecs" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[PrivateIpAddress]" --output text
$ ssh -i devtools-key ec2-user@`aws ec2 describe-instances --filters "Name=tag:Name,Values=devtools-instance-ecs" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[PrivateIpAddress][0]" --output text` -o 'ProxyCommand ssh -i devtools-key -W %h:%p ec2-user@`terraform output bastion_ip`'
Run after starting bastion instance
Get runner unregistering command and copy it
$ terraform output gitlab_runner_unregister
Log in bastion and run the runner unregistering command
Log in ecs instance that has GitLab container
Run the following command
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:backup:create
Reference: Creating backups for GitLab instances in Docker containers
Log in ecs instance that has GitLab container
Run the following commands
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl stop unicorn
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl stop sidekiq
$ docker exec -it `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:backup:restore BACKUP=1510107973_2017_11_08_10.1.1
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl restart
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:check SANITIZE=true
Reference: Restore for Omnibus installations