Skip to content

Instantly share code, notes, and snippets.

@jweslley
Last active December 16, 2015 12:49
Show Gist options
  • Select an option

  • Save jweslley/5437568 to your computer and use it in GitHub Desktop.

Select an option

Save jweslley/5437568 to your computer and use it in GitHub Desktop.

Revisions

  1. jweslley revised this gist Apr 22, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitlab.sh
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ set -e

    DB_USERNAME=username
    DB_PASSWORD=secret
    BACKUP_DIR='/path/to/backup/'

    BACKUP_DIR='/mnt/backup/gitlab/'
    TIMESTAMP=`date +'%Y%m%d%H%M%S'`

    # Mysql database
  2. jweslley created this gist Apr 22, 2013.
    28 changes: 28 additions & 0 deletions gitlab.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/sh
    # Usage:
    # - Save this file in /etc/cron.daily/gitlab
    # - Enable execution permission: chmod +x /etc/cron.daily/gitlab

    set -e

    DB_USERNAME=username
    DB_PASSWORD=secret

    BACKUP_DIR='/mnt/backup/gitlab/'
    TIMESTAMP=`date +'%Y%m%d%H%M%S'`

    # Mysql database
    mysqldump --user=$DB_USERNAME --password='$DB_PASSWORD' gitlabhq_production | gzip > "$BACKUP_DIR/$TIMESTAMP-mysql.sql.gz"

    # Uploads
    tar zcf "$BACKUP_DIR/$TIMESTAMP-uploads.tar.gz" \
    --directory /home/git/gitlab/public/ \
    uploads

    # Git repositories
    tar zcf "$BACKUP_DIR/$TIMESTAMP-repositories.tar.gz" \
    --directory /home/git/ \
    repositories

    # Remove backup files older than 5 days
    find $BACKUP_DIR -mtime +5 -type f -exec rm {} \;