diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-05-21 10:52:06 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-05-21 10:52:06 +0000 |
commit | 47f8006f6c1635d8b1af216b65e4a99a707caa66 (patch) | |
tree | 460584a7fc05c5e8c92dccaf3b8e86e88e462461 | |
parent | 2d7145be1ea96d345b494da30291a4f5eb1c922c (diff) | |
parent | cd86b155042f6fca18c231b862d8e923eb38b441 (diff) | |
download | definitions-47f8006f6c1635d8b1af216b65e4a99a707caa66.tar.gz |
Merge remote-tracking branch 'origin/baserock/liw/gitlab-backup-cronjob'
Reviewed-by: Daniel Silverstone (email)
Reviewed-by: Richard Maw (irc)
5 files changed, 45 insertions, 1 deletions
diff --git a/gitlab-server/manifest b/gitlab-server/manifest index 8d1dae7a..7ac74744 100644 --- a/gitlab-server/manifest +++ b/gitlab-server/manifest @@ -1,5 +1,6 @@ 0100755 0 0 /usr/share/gitlab-setup 0040755 0 0 /usr/share/gitlab-install +0100755 0 0 /usr/share/gitlab-install/backup-gitlab 0040755 0 0 /usr/share/gitlab-install/gitlab 0040755 0 0 /usr/share/gitlab-install/gitlab/config 0100644 0 0 /usr/share/gitlab-install/gitlab/config/gitlab.yml @@ -32,3 +33,5 @@ 0100644 0 0 /usr/share/gitlab-install/systemd-units/nginx.service 0100644 0 0 /usr/share/gitlab-install/systemd-units/postgres.service 0100644 0 0 /usr/share/gitlab-install/systemd-units/redis.service +0100644 0 0 /usr/share/gitlab-install/systemd-units/gitlab-backup.service +0100644 0 0 /usr/share/gitlab-install/systemd-units/gitlab-backup.timer diff --git a/gitlab-server/usr/share/gitlab-install/backup-gitlab b/gitlab-server/usr/share/gitlab-install/backup-gitlab new file mode 100644 index 00000000..a6c3e3f5 --- /dev/null +++ b/gitlab-server/usr/share/gitlab-install/backup-gitlab @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Run the gitlab backup script. The backup will be stored as +# /home/git/gitlab-backup.tar . A separate backup host will need to +# back that up. +# +# This script be run as the git user on a GitLab host. + +set -e + +export PATH=/usr/local/bin:/usr/bin:/bin + +cd /home/git/gitlab +mkdir -p /home/git/gitlab/tmp/backups +bundle exec rake gitlab:backup:create RAILS_ENV=production + +ls /home/git/gitlab/tmp/backups/[0-9]*.tar | +tail -n1 | +while read filename +do + mv "$filename" /home/git/gitlab-backup.tar +done diff --git a/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.service b/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.service new file mode 100644 index 00000000..967a65e3 --- /dev/null +++ b/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.service @@ -0,0 +1,11 @@ +[Unit] +Description=GitLab Backup Run +After=postgres.service + +[Install] +WantedBy=gitlab.target + +[Service] +ExecStart=/usr/share/gitlab-install/backup-gitlab +User=git +Group=git diff --git a/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.timer b/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.timer new file mode 100644 index 00000000..1c2f57ba --- /dev/null +++ b/gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.timer @@ -0,0 +1,8 @@ +[Unit] +Description=GitLab Backup Timer + +[Install] +WantedBy=gitlab.target + +[Timer] +OnCalendar=*-*-* 00/4:00:00 diff --git a/gitlab-server/usr/share/gitlab-setup b/gitlab-server/usr/share/gitlab-setup index 5c53c859..e1084a1b 100755 --- a/gitlab-server/usr/share/gitlab-setup +++ b/gitlab-server/usr/share/gitlab-setup @@ -100,5 +100,5 @@ cp /usr/share/gitlab-install/nginx.conf /etc/nginx/nginx.conf # make systemd units to start gitlab and required stuff on boot cd /etc/systemd/system cp /usr/share/gitlab-install/systemd-units/* . -systemctl enable redis.service nginx.service postgres.service gitlab.target gitlab-unicorn.service gitlab-sidekiq.service gitlab-ci-sidekiq.service gitlab-ci-unicorn.service +systemctl enable redis.service nginx.service postgres.service gitlab.target gitlab-unicorn.service gitlab-sidekiq.service gitlab-ci-sidekiq.service gitlab-ci-unicorn.service gitlab-backup.timer gitlab-backup.service reboot |