-
Notifications
You must be signed in to change notification settings - Fork 9
/
atlassian_fs_backup
executable file
·81 lines (72 loc) · 2.19 KB
/
atlassian_fs_backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Creates a filesystem backup of Confluence or JIRA
# Must be root to run this script
if [ "`/usr/bin/id -urn`" != "root" ] ; then
echo -e "\nYou must be root to execute this script \n"
exit 1
fi
USAGE() {
echo -e "\nUsage: `basename $0` [ -c | -j ] "
echo -e "-c --> Backup Confluence filesystem"
echo -e "-j --> Backup JIRA filesystem"
}
BACKUP_DIR="/atlassianbackup"
INSTALL_DIR="/usr/local/atlassian"
HOME_DIR="/var/atlassian/application-data"
BIN_DIR="null"
APP="null"
while getopts ":cj" OPT ; do
case $OPT in
c)
APP="confluence"
ENV_FILE="$INSTALL_DIR/confluence/bin/user.sh"
INSTALL_DIR_ARCH=confluence_installdir_`date "+%Y%m%d"`_$$.tar.gz
HOME_DIR_ARCH=confluence_homedir_`date "+%Y%m%d"`_$$.tar.gz
;;
j)
APP="jira"
ENV_FILE="$INSTALL_DIR/jira/bin/user.sh"
INSTALL_DIR_ARCH=jira_installdir_`date "+%Y%m%d"`_$$.tar.gz
HOME_DIR_ARCH=jira_homedir_`date "+%Y%m%d"`_$$.tar.gz
;;
\?)
echo -e "\nInvalid option: -$OPTARG" >&2
USAGE
exit 1
;;
:)
echo -e "\nOption -$OPTARG requires an argument" >&2
USAGE
exit 1
;;
esac
done
if [ "$APP" == "null" ] ; then
USAGE
exit 1
fi
# Perform check to determine if this script can run on this server
if [ ! -s $ENV_FILE ] ; then
echo -e "\nCould not locate a $APP installation on this system \n"
exit 1
fi
echo -e "Starting back-up of the $APP filesystem \n"
echo -e "Backing-up $APP Installation directory..."
tar czf $BACKUP_DIR/$INSTALL_DIR_ARCH -C $INSTALL_DIR . > /dev/null 2>&1
if [ $? -ne 0 -a $? -ne 1 ] ; then
echo -e "\nFailed to create the Installation directory archive - exiting \n"
if [ -f $BACKUP_DIR/$INSTALL_DIR_ARCH ]; then
rm -f $BACKUP_DIR/$INSTALL_DIR_ARCH
fi
exit 1
fi
echo -e "Backing-up $APP Home directory..."
tar czf $BACKUP_DIR/$HOME_DIR_ARCH -C $HOME_DIR . > /dev/null 2>&1
if [ $? -ne 0 -a $? -ne 1 ] ; then
echo -e "\nFailed to create the Home directory archive - exiting \n"
if [ -f $BACKUP_DIR/$HOME_DIR_ARCH ]; then
rm -f $BACKUP_DIR/$HOME_DIR_ARCH
fi
exit 1
fi
echo -e "\nBackup is complete and is available at $BACKUP_DIR/$INSTALL_DIR_ARCH and $BACKUP_DIR/$HOME_DIR_ARCH"