How to enable cron backup in docker gitlab-ce

I use this Docker Image to installgitlab-ce

To configure it, you can override the file with the name gitlab.rbby setting it as the volume in./gitlab.rb:/etc/gitlab/gitlab.rb:ro

You can find gitlab.rb here

In the backup section, I have the following:

## For setting up backups
## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#backups

# gitlab_rails['manage_backup_path'] = true
# gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
gitlab_rails['backup_archive_permissions'] = 0644 # See: http://doc.gitlab.com/ce/raketasks/backup_restore.html#backup-archive-permissions
# gitlab_rails['backup_pg_schema'] = 'public'
gitlab_rails['backup_keep_time'] = 604800
# gitlab_rails['backup_upload_connection'] = {
#   'provider' => 'AWS',
#   'region' => 'eu-west-1',
#   'aws_access_key_id' => 'AKIAKIAKI',
#   'aws_secret_access_key' => 'secret123'
# }
# gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket'
# gitlab_rails['backup_multipart_chunk_size'] = 104857600
# gitlab_rails['backup_encryption'] = 'AES256' # Turns on AWS Server-Side Encryption with Amazon S3-Managed Keys for backups

If you see the link as recommended in the code , it says:

# Scheduling a backup

To schedule a cron job that backs up your repositories and GitLab metadata, use the root user:
    sudo su -
    crontab -e
There, add the following line to schedule the backup for everyday at 2 AM:
    0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

Questions

  • Is there a way to do this during installation, and not do it manually?
  • Is the cron task in progress? If we don’t start it by doing crontab -f?
  • Which file modifies the command crontab -e?
  • , cron , /etc/cron.d/my-backup-cron, ?
+4
2

, BigDong... Docker , init, . , , CMD Dockerfile ( ENTRYPOINT), PID1 . service myservice start .

" " - gitlab-ce. , docker run "" gitlab-ce, , cron . docker run. , . - :

docker run -d --rm gitlab-ce sh -c "/opt/gitlab/bin/gitlab-rake gitlab:backup:create"

( ), :

docker run -d --rm --volumes-from gitlab-ce gitlab-ce sh -c "/opt/gitlab/bin/gitlab-rake gitlab:backup:create"

"" gitlab-ce --volumes-from gitlab-ce ( - , gitlab-ce), , . , S3 , , . , , .

, , , , , , gitlab-ce, , . , sh -c gitlab-rake . crontab -e , :

0 2 * * * docker run -d --rm gitlab-ce sh -c "...gitlab-rake..."

--rm. Docker , docker ps -a.

, , - gitlab-ce , -, . , , . gitlab-rake.

, - , cron, docker run docker exec .

Gitlab... Gitlab. , , . , S3, cron , S3. , , , . , ( ), . , , , Docker .

, Docker , . , , , . !

tl; dr docker run, gitlab-ce (gitlab-rake), cronjob, .

+8

"" , Gitlab Doku, :

docker exec -t <your container name> gitlab-rake gitlab:backup:create
+4

Source: https://habr.com/ru/post/1617768/


All Articles