2016-10-15 19:31:55 +02:00
|
|
|
#!/usr/bin/env bash
|
2017-01-21 01:20:27 +01:00
|
|
|
#
|
2016-05-07 22:03:04 +02:00
|
|
|
# needs to run as root
|
2017-01-21 01:20:27 +01:00
|
|
|
#
|
|
|
|
# setup as cron job:
|
|
|
|
#
|
|
|
|
# sudo crontab -e
|
|
|
|
# 0 2 * * * /bin/gitlab-backup.sh
|
|
|
|
#
|
2016-05-07 22:03:04 +02:00
|
|
|
|
|
|
|
# Create a time-stamped .tar file in the current directory.
|
|
|
|
# The .tar file will be readable only to root.
|
2017-07-29 20:27:19 +02:00
|
|
|
cd /var/opt/gitlab/backups/ || exit
|
2017-01-21 01:20:27 +01:00
|
|
|
sh -c 'umask 0077; tar -cf $(date "+%s-%F-etc-gitlab.tar") -C / etc/gitlab'
|
2016-05-07 22:03:04 +02:00
|
|
|
|
2017-01-21 01:11:07 +01:00
|
|
|
# run GitLab system backup
|
|
|
|
gitlab-rake gitlab:backup:create CRON=1
|
|
|
|
|
|
|
|
# sync with Google Cloud Storage bucket
|
|
|
|
/home/m/code/google-cloud-sdk/bin/gsutil rsync -r . gs://git-berlin-backups
|