summaryrefslogtreecommitdiff
path: root/gitlab-server
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-05-19 16:20:53 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-05-20 14:23:45 +0000
commitcd86b155042f6fca18c231b862d8e923eb38b441 (patch)
treeef877aede038726888dd50e34331af4a1c84e3f2 /gitlab-server
parentbc347a438b36c60931602bf86d4156d332cb9cde (diff)
downloaddefinitions-cd86b155042f6fca18c231b862d8e923eb38b441.tar.gz
Add GitLab backup automation
This adds a systemd timer unit to back up a GitLab instance every four hours. The backup is placed as /home/git/gitlab-backup.tar and it is expected Something Else retrieves that.
Diffstat (limited to 'gitlab-server')
-rw-r--r--gitlab-server/manifest3
-rw-r--r--gitlab-server/usr/share/gitlab-install/backup-gitlab22
-rw-r--r--gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.service11
-rw-r--r--gitlab-server/usr/share/gitlab-install/systemd-units/gitlab-backup.timer8
-rwxr-xr-xgitlab-server/usr/share/gitlab-setup2
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