Moving WARs You Copy with rsync into an Artifact Repository, Step by Step

Running the same rsync command twice and deploying two different versions is a problem of how you pick the file, not how you copy it. Keep your rsync transfer and introduce an artifact repository over three deploys: archive first, then switch the input, then test retries.

John Baek
John Baek
Founder, CollabOps
2 min read

We sent the WAR to production server A, and then server B's maintenance window slipped. The next day the same script sent the file to B. Both runs succeeded. But if out/portal.war on the build server was replaced in between, we ran the same command twice and deployed two different versions.

The first thing to fix isn't the copy command. It's how the file to copy gets chosen. rsync can keep doing the transfer. An artifact repository stores build outputs by version, so if you retry the same deploy tomorrow you can pull out the exact file you approved today. Using the two together means you don't have to replace your existing operating procedure all at once. (Server names and build numbers are illustrative.)

What makes the same deploy command send the same file is not the transfer tool. It is a repository that pins approved builds by version so you can pull them out again.

In what order do you migrate while keeping the existing rsync procedure?

Over three deploys: archive, switch the input, then test retries.

On the first deploy, start by archiving. Take the WAR you already build and, when the build finishes, register it as portal/2.4.7/build-218/portal.war. Record the commit, build number and the file's SHA-256 alongside it, and set a repository policy so nothing can overwrite a published path. If you rebuild the same product version, give it a new build number. Generic package registries support registering a file with its version and SHA-256 too. GitLab's generic packages are one example.

On the second deploy, switch the input. Where the operator used to pick "the most recently built file," put the approved build number instead. If production can't reach the repository directly, your existing deploy relay can fetch build 218 and keep using rsync to push it to target servers. At that point, compare the hash of the file each server actually received, and install only on servers where it matches.

On the third deploy, test the retry. Deploy 218 to A and deliberately hold B. Meanwhile, register a new build, 219. When you resume the original deploy on B a few hours later, 218 should still be what gets installed. Attach each server's receipt result and the build number that actually started, and at the next day's handover you can say "B got the version we approved yesterday."

How do you verify the migration is actually done?

One question is enough. "After the latest build has changed, can you redeploy just the one server that failed last Friday, using the build that was approved then?" If that test passes, the change in how you store files has turned into a real operational improvement.

Do emergency patches need to go through the repository too?

Yes. Even an emergency patch to part of a WAR eventually needs a proper build number and a place in this repository, or the next server you add won't get the same file. What to record until the patch lands in a regular build is in patching one file inside a WAR: what should a partial deploy record?.

  • #legacy-deploy
  • #artifact-repository
  • #war
  • #rsync
  • #supply-chain
  • #deployment