3. Backup

3.1. Procedure

  • XML (http://localhost:8080/secure/admin/XmlBackup!default.jspa)

  • rsync:

    • JIRA_HOME="/var/atlassian/application-data/jira"

    • JIRA_INSTALL="/opt/atlassian/jira/"

    • database replication

    • pg_dump i pg_restore

  • database replication consistency and rsync while upgrading

  • /var/atlassian/application-data/jira/.jira-home.lock

  • Cold standby in alternative datacenter

  • database replication between datacenter

  • cold standby and licensing (same SEN number)

3.2. Script

Listing 3.1. Jira backup
#!/bin/bash

echo "[$(date)] Reading database configuration..."
USER=$(cat /opt/jira/home/dbconfig.xml |xmllint --xpath '//username/text()' -)
export PGPASSWORD=$(cat /opt/jira/home/dbconfig.xml |xmllint --xpath '//password/text()' -)
HOST=$(cat /opt/jira/home/dbconfig.xml |xmllint --xpath '//url/text()' - |awk -F'/' '{print $3}' |awk -F':' '{print $1}')
PORT=$(cat /opt/jira/home/dbconfig.xml |xmllint --xpath '//url/text()' - |awk -F'/' '{print $3}' |awk -F':' '{print $2}')
DATABASE=$(cat /opt/jira/home/dbconfig.xml |xmllint --xpath '//url/text()' - |awk -F'/' '{print $4}')

echo "[$(date)] Database connection settings..."
echo "User: $USER"
echo "Pass: **********" #$PGPASSWORD"
echo "Host: $HOST"
echo "Port: $PORT"
echo "Database: $DATABASE"

echo "[$(date)] Cleanup previous backups..."
rm -fr /opt/jira/backup/*

echo "[$(date)] Backup database..."
pg_dump -h $HOST -p $PORT -U $USER $DATABASE |gzip > /opt/jira/backup/jira-database_$(date +%F).tar.gz

echo "[$(date)] Backup home directory..."
tar -jcf /opt/jira/backup/jira-home_$(date +%F).tar.bz2 --exclude-caches-all /opt/jira/home

echo "[$(date)] All done."

3.3. Assignments

3.3.1. Administracja - backup

  1. Zrób backup $JIRA_HOME i $JIRA_INSTALL wykorzystując tar.gz (musi być data w nazwie pliku)

  2. Wylistuj pliki w archiwum (możesz przeglądnąć za pomocą midnight commander)

  3. Usuń katalogi $JIRA_HOME i $JIRA_INSTALL

  4. Przywróć oba katalogi do:

    • /opt/jira/home

    • /opt/jira/install

  5. Podmienić skrypty startowe

  6. Uruchom Jirę z nowej lokalizacji

  7. Dodaj polecenie backupu $JIRA_HOME i $JIRA_INSTALL do crontab z @midnight