I recently published https://hg.sr.ht/~redradishtech/versioned_directories, a script to manage the seemingly trivial task of keeping a
/opt/atlassian/jira/current symlink pointing to the correct
/opt/atlassian/jira/$version; or more generally, managing a directory containing N versions of something.
We know JIRA's application files usually go in:
and the home directory goes in:
but what happens below those directories?
We could just dump JIRA in
/opt/atlassian/jira, like the Atlassian installer does, but then on upgrade there is no safe rollback path. Likewise with the home directory: if we only have one copy in
/var/atlassian/application-data/jira, and an upgrade goes wrong, we're left having to restore from backup.
The standard I follow is to keep the current and previous releases in versioned directories, with
All versions older than
previous get moved to
old/, and eventually deleted.
Each old version has an
UPGRADED_TO_$newver.txt marker file, to clearly indicate that it is no longer current:
Upgrading involves deploying a new release to
previous symlinks, and moving the old
previous directory into
The JIRA home directory is just the same:
If I have to roll back, then the abandoned new version directory is pointed to with a
next/ symlink, and get a DOWNGRADED_TO_$oldver.txt marker.
What do the scripts do?
Say JIRA 9.0 arrives. I would unpack JIRA 9.0 into
/opt/atlassian/jira/9.0, and then:
8.5.1 is stashed away in old/
Say 9.0 is a lemon. To downgrade:
Notice how the script restored the
previous/ symlink, figuring out what it should be by looking at the marker files. In fact, I can
downgrade through the entire sequence of versions available.
Is this rocket science?
No, but having marker files, an always-consistent structure, and a command to rollback or rollforward quickly is nice. The structure works well in non-obvious ways:
- You can make
old/a separate partition, and rollback will still be fast, because the
previous/version isn't yet moved to
- You can have replication, and upgrade your replication standby safely. prod:/opt/atlassian/jira/8.10.0/ can keep replicating to sandbox:/opt/atlassian/jira/8.10.0/ even if you deployed sandbox:/opt/atlassian/jira/9.0/
- Your backups will be consistent even if they occur halfway though an upgrade, at least if you hardcode versions. E.g. if rsnapshot is backing up /var/atlassian/application-data/jira/8.10.0/, it doesn't matter if /var/atlassian/application-data/jira/9.0 goes live.
It's all wrapped up in a nice script. Give it a try!