Skip to content

Instantly share code, notes, and snippets.

@alekstrust
Last active August 26, 2017 03:01
Show Gist options
  • Save alekstrust/ee3e5cb1f8f4238c264544de1f957e63 to your computer and use it in GitHub Desktop.
Save alekstrust/ee3e5cb1f8f4238c264544de1f957e63 to your computer and use it in GitHub Desktop.
Confluence to Google Drive
#!/bin/bash
# This is a script to take a MySQL dump and upload to Google Drive.
# Uses gdrive https://github.com/prasmussen/gdrive. See the gdrive readme first.
# The path to the gdrive binary
GDRIVE_BIN=/usr/sbin/gdrive
# Use "gdrive list" to get the id of the directory where you want to upload the files
BACKUP_DRIVE_DIR=
# Set your MySQL password. You can also use a config fille https://dev.mysql.com/doc/refman/5.7/en/password-security-user.html
MYSQL_PASS=
# The directory where your data is stored
DATA_DIR=/home/confluence
# The directory where the generated backup will be stored
BACKUP_DEST_DIR=/home/backup/confluence/`date +%Y%m%d-%H%M%S`
# The database you want to backup
DATABASE_NAME=confluence
DATABASE_USER=confluence
echo "Backup from dir: $DATA_DIR"
echo "Backup to dir: $BACKUP_DEST_DIR"
echo "Google Drive Directory ID: $BACKUP_DRIVE_DIR"
rm -rf $DATA_DIR/temp/*
mkdir -p $BACKUP_DEST_DIR
mysqldump -u $DATABASE_USER -p"$MYSQL_PASS" $DATABASE_NAME | gzip > $BACKUP_DEST_DIR/db-confluence-`date +%Y%m%d-%H%M%S`.sql.gz
echo "MySQL backup completed"
tar -cjvf $BACKUP_DEST_DIR/data-confluence-`date +%Y%m%d-%H%M%S`.bzip $DATA_DIR > $BACKUP_DEST_DIR/homedir.status
echo "Confluence data backup completed"
echo "Sending to Google Drive"
$GDRIVE_BIN upload -r -p $BACKUP_DRIVE_DIR $BACKUP_DEST_DIR
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment