mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-25 14:08:09 +00:00
gitlab: added feature to setup automated daily/monthly backups
This commit is contained in:
parent
f06c4edf1e
commit
0167f53a5a
@ -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.
|
||||
|
||||
@ -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 <<EOF
|
||||
00 02 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production
|
||||
EOF
|
||||
;;
|
||||
monthly)
|
||||
cat >> /tmp/cron.git <<EOF
|
||||
00 02 01 * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production
|
||||
EOF
|
||||
;;
|
||||
disable|*)
|
||||
;;
|
||||
esac
|
||||
crontab -u git /tmp/cron.git && rm -rf /tmp/cron.git
|
||||
|
||||
# kickstart the rails application
|
||||
wget "http://localhost" -O /dev/null
|
||||
|
||||
|
||||
# watch the access logs
|
||||
tail -F /var/log/nginx/gitlab_access.log
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user