Last active
December 20, 2015 16:18
-
-
Save DominicImhof/b4d7f758f3bf34a995bc to your computer and use it in GitHub Desktop.
Auto GitLab backup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REMOTE_HOST=backup4.skilia.ch | |
REMOTE_USER=backup | |
REMOTE_PATH=/home/backup/gitlab-backups/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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