Skip to content

Instantly share code, notes, and snippets.

@DominicImhof
Last active December 20, 2015 16:18
Show Gist options
  • Save DominicImhof/b4d7f758f3bf34a995bc to your computer and use it in GitHub Desktop.
Save DominicImhof/b4d7f758f3bf34a995bc to your computer and use it in GitHub Desktop.
Auto GitLab backup script
REMOTE_HOST=backup4.skilia.ch
REMOTE_USER=backup
REMOTE_PATH=/home/backup/gitlab-backups/
#!/bin/bash
readonly BACKUP_DIR="/var/opt/gitlab/backups/"
readonly CONFIG_FILE="$HOME/.gitlab-backup"
check_config() {
if [[ ! -f $CONFIG_FILE ]]
then
echo "No config file detected"
exit 0
fi
}
do_gitlab_backup() {
gitlab-rake gitlab:backup:create
}
sync_backup_dir() {
rsync -avz --delete $BACKUP_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH
}
main() {
check_config
source $CONFIG_FILE
echo "Do GitLab-Backup"
do_gitlab_backup
echo "Sync backup dir to $REMOTE_HOST"
sync_backup_dir
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment