From 0167f53a5afddd7896a827c8b630fa3840e7cb26 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Tue, 25 Feb 2014 23:33:41 +0530 Subject: [PATCH] gitlab: added feature to setup automated daily/monthly backups --- README.md | 8 ++++++++ resources/gitlab | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 8751a136..ba1b1dd6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ - [SSH Login](#ssh-login) - [Taking Backups](#taking-backups) - [Restoring Backups](#restoring-backups) + - [Automated Backups](#automated-backups) - [Upgrading](#upgrading) - [Rake Tasks](#rake-tasks) - [References](#references) @@ -266,6 +267,7 @@ Below is the complete list of available options that can be used to customize yo - **GITLAB_EMAIL**: The email address for the GitLab server. Defaults to gitlab@localhost. - **GITLAB_SUPPORT**: The support email address for the GitLab server. Defaults to support@localhost. - **GITLAB_SIGNUP**: Enable or disable user signups. Default is false. +- **GITLAB_BACKUPS**: Setup cron job to automatic backups. Possible values disable, daily or monthly. Disabled by default - **GITLAB_SHELL_SSH_PORT**: The ssh port number. Defaults to 22. - **REDIS_HOST**: The hostname of the redis server. Defaults to localhost - **REDIS_PORT**: The connection port of the redis server. Defaults to 6379. @@ -329,6 +331,12 @@ docker run -i -t -rm [OPTIONS] sameersbn/gitlab app:rake gitlab:backup:restore The restore operation will list all available backups in reverse chronological order. Select the backup you want to restore and gitlab will do its job. +### Automated Backups + +The image can be configured to automatically take backups on a daily or monthly basis. Adding -e "GITLAB_BACKUPS=daily" to the docker run command will enable daily backups, while -e "GITLAB_BACKUPS=monthly" will enable monthly backups. + +Daily backups are created at 02 am (UTC) everyday, while monthly backups are created on the 1st of every month at the same time as the daily backups. + ## Upgrading GitLabHQ releases new versions on the 22nd of every month, bugfix releases immediately follow. I update this project almost immediately when a release is made (at least it has been the case so far). If you are using the image in production environments I recommend that you delay updates by a couple of days after the gitlab release, allowing some time for the dust to settle down. diff --git a/resources/gitlab b/resources/gitlab index 39219f5b..825dc71b 100755 --- a/resources/gitlab +++ b/resources/gitlab @@ -9,6 +9,8 @@ GITLAB_EMAIL=${GITLAB_EMAIL:-gitlab@localhost} GITLAB_SUPPORT=${GITLAB_SUPPORT:-support@localhost} GITLAB_SIGNUP=${GITLAB_SIGNUP:-false} +GITLAB_BACKUPS=${GITLAB_BACKUPS:-disable} + GITLAB_SHELL_SSH_PORT=${GITLAB_SHELL_SSH_PORT:-22} REDIS_HOST=${REDIS_HOST:-localhost} @@ -248,9 +250,30 @@ gitlab_start () { sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + # setup cron job for automatic backups + set +e + crontab -l -u git > /tmp/cron.git + set -e + case "${GITLAB_BACKUPS}" in + daily) + cat >> /tmp/cron.git <> /tmp/cron.git <