#!/bin/bash
###
### Find out what day this is.
###
d="$(date +%F)"
### Tip: for testing, reset "d"
#d="testing4"
###
### Make back up file for Jira database.
### Doing this first to ensure that anything mentioned
### in the SQL already exists in the Jira home
### location. Maybe later we can shutdown access to the
### host while this is going on. But I don't think this
### is needed right now, considering we only have a few
### users with write access to Jira, currently.
###
s="jira_$d.sql.gz"
echo "Making back up file $s for Jira database."
fname="$HOME/backups/jiraSQL/$s"
mysqldump -u jira -pjira jira --no-tablespaces | gzip -9 > $fname
###
### Make back up file for Jira home directory.
###
s="jiraHome_$d.tar.gz"
echo "Making back up file $s for Jira home directory."
fname="$HOME/backups/jiraHome/$s"
tar czfP $fname -C ../jiradata jiraHome
###
### Copy Jira database back up file to s3.
###
s="jira_$d.sql.gz"
fname="$HOME/backups/jiraSQL/$s"
echo "Copying $s to s3, unless an identical object with the same name already exists in the s3 bucket."
aws s3 sync --exclude '*' --include "$s" $HOME/backups/jiraSQL s3:echo "Completed copy of $s to s3."
echo "Checking that an object called $s exists in s3."
VAR=$(aws s3 ls s3:if [ -z "${VAR}" ]; then
echo "Backup to s3 failed for file $s."
else
echo "An object named $s exists in s3 bucket, so removing local copy $fname."
CMD="rm $fname"
$CMD
echo "Backup of $s succeeded."
fi
###
### Copy Jira home back up file to s3.
###
s="jiraHome_$d.tar.gz"
fname="$HOME/backups/jiraHome/$s"
echo "Copying $s to s3, unless an identical object with the same name already exists in the s3 bucket."
aws s3 sync --exclude '*' --include "$s" $HOME/backups/jiraHome s3:echo "Completed copy of $s to s3."
echo "Checking that an object called $s exists in the s3 bucket."
VAR=$(aws s3 ls s3:if [ -z "${VAR}" ]; then
echo "Backup to s3 failed for file $s."
else
echo "An object named $s exists in the s3 bucket, so removing local copy $fname."
CMD="rm $fname"
$CMD
echo "Backup of $s succeeded."
fi
Rebooted confluence. Removed backup files to make more space on the server.
I need to create a script that will remove these backup files after they have been copied to the S3 bucket.