Repository navigation
Updating Your Deployment
Moving a running vault to a new release: check out its tag, reapply the instance metadata, reboot.
This page is for a deployment already on its data disk at /mnt/disks/bwgc.¹ It is not the OS upgrade, which is Upgrading Container-Optimized OS.
Open a Cloud Shell session with INSTANCE and ZONE exported, from Cloud Shell Setup.
Check that you are the login that owns the deployment:²
gcloud compute ssh $INSTANCE --zone $ZONE --command 'stat -c "%U" /mnt/disks/bwgc/bitwarden_gcloud; whoami'
The two names should match. If they differ, connect from the machine that installed it, or as that user with gcloud compute ssh USER@$INSTANCE.
gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && git fetch -q --tags origin && git describe --tags --always && git tag -l "v*" --sort=-v:refname | head -1 && git status --porcelain'
This prints the release or commit you are on, the newest release, and any local modifications. Note the first line for rolling back. Set the newest release for the steps below:
export TAG=$(git ls-remote --tags --refs --sort=-v:refname https://github.com/dadatuputi/bitwarden_gcloud 'v*' | head -1 | sed 's|.*/||')
echo "$TAG"
It should print the same release as the second line above.
Read the Before you update section of each release newer than yours.¹³
If there are local modifications, compare them against the release:³
gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && git diff'
gcloud compute ssh $INSTANCE --zone $ZONE --command 'docker exec backup ash /backup.sh local'
gcloud compute ssh $INSTANCE --zone $ZONE --command 'ls -lt /mnt/disks/bwgc/bitwarden_gcloud/bitwarden/backups/ | head -3'
The newest entry should carry today's timestamp.⁴
gcloud compute ssh $INSTANCE --zone $ZONE --command 'sudo systemctl stop bwgc-supervise.timer'
Skip this if systemctl list-unit-files bwgc-supervise.timer reports nothing.⁵
gcloud compute ssh $INSTANCE --zone $ZONE --command "cd /mnt/disks/bwgc/bitwarden_gcloud && git checkout -- docker-compose.yml && git checkout -q ${TAG:?} && git describe --tags"
It should print the release you set.¹⁴
To keep a local change instead, commit it first and expect to resolve a conflict.⁶
If the checkout reports Permission denied on bitwarden/backups/.gitignore, restore that file:⁷
gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && sudo git checkout -- bitwarden/backups/.gitignore && git status --porcelain'
Refresh the scripts in ~/bwgc first:⁸
cd ~/bwgc
for f in lib-bwgc-cloudinit.sh migrate-to-data-disk.sh upgrade-cos.sh install-cos-update-reboot.sh; do
curl -fsSLO "https://raw.githubusercontent.com/dadatuputi/bitwarden_gcloud/$TAG/utilities/$f"
done
chmod +x migrate-to-data-disk.sh upgrade-cos.sh install-cos-update-reboot.sh
Then generate the configuration, back up the current one, and apply it. Add --disk-name if your disk is not bwgc-data.⁹
./migrate-to-data-disk.sh --print-cloud-config > cloud-config.yaml
gcloud compute instances describe $INSTANCE --zone $ZONE --format='value(metadata.items.user-data)' > user-data.backup
gcloud compute instances add-metadata $INSTANCE --zone $ZONE --metadata-from-file user-data=cloud-config.yaml
If add-metadata reports No change requested; skipping update, compare the two:¹⁰
diff <(./migrate-to-data-disk.sh --print-cloud-config) user-data.backup
gcloud compute ssh $INSTANCE --zone $ZONE --command 'sync; sudo systemctl reboot'
The connection drops and the command exits non-zero. Give it three to five minutes.¹¹
gcloud compute ssh $INSTANCE --zone $ZONE --command 'docker ps -a --format "{{.Names}}\t{{.Status}}"'
Compare that against what you had before. watchtower should be listed.¹²
gcloud compute ssh $INSTANCE --zone $ZONE --command 'df -h /mnt/disks/bwgc; systemctl is-active bwgc.service bwgc-supervise.timer; docker ps --format "{{.Names}}\t{{.Status}}"'
You should see the disk mounted, both units active, and every container Up. Then load your vault in a browser and log in from a real client.
A release that moves an image to a new tag leaves the old image behind on the boot disk. Once every container is Up, remove images no container uses:¹⁵
gcloud compute ssh $INSTANCE --zone $ZONE --command 'docker image prune -af'
If docker ps is short, the stack is still coming up. sudo journalctl -u bwgc.service -b shows what happened.
The metadata:
gcloud compute instances add-metadata $INSTANCE --zone $ZONE --metadata-from-file user-data=user-data.backup
The code:
gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && git checkout <the release or commit Step 1 printed>'
Then reboot as in Step 6. Your vault data is on the data disk and is not affected by either.
1. A deployment still in ~/bitwarden_gcloud that predates the backup service follows A deployment older than mid-2023 instead, then migrates. This page updates the project's own files on an instance that stays where it is.
2. git refuses to operate on a repository owned by another user, reporting detected dubious ownership. Two different names means the deployment was installed from another machine.
3. Local modifications are common on a deployment that was hardened by hand before the same changes landed upstream.
4. The update rewrites docker-compose.yml and the utility scripts. It does not touch your vault, but a fresh backup costs nothing.
5. bwgc-supervise.timer runs compose up -d every five minutes and would start containers against half-updated files. Deployments without a data disk do not have it.
6. Your .env is not tracked and is never touched by a checkout.
7. bitwarden/backups is written by containers running as root, so git checkout cannot restore the tracked .gitignore inside it. The checkout itself still succeeds.
8. The cloud-config carries the disk mount, the startup units and the timers. It is generated by the scripts in ~/bwgc, a copy you downloaded earlier that does not update itself. Without the refresh you generate the configuration you already have, and the update silently does nothing.
9. add-metadata replaces the whole key rather than merging, which is why the backup is worth taking.
10. No change requested means the generated configuration matches what the instance already has. That is correct when nothing relevant changed, and a sign you skipped the refresh when something did.
11. Metadata takes effect at the next boot. Reboot from inside the guest: gcloud compute instances reset is a power cycle that can truncate a file written seconds earlier, and stopping the instance releases its external address. The non-zero exit is the reboot working.
12. watchtower applies image updates, and runs by default from v3.0.0. A deployment on code from before January 2026 may still run the abandoned containrrr/watchtower, which no longer works with current Docker; this update replaces it. To stop it updating, see Operations.
13. The major version changes when an existing deployment has to do something by hand. Minor and patch releases need only this page.
14. git reports a detached HEAD. That is expected: the deployment sits on a release, not a branch. To follow unreleased changes instead, check out master and pull it.
15. v3.1.0 is one such release: the project's own images move from :master to their major version tag, :1. watchtower removes the images it replaces, but not one that a checkout stopped using. The boot disk is 10 GB on current installs, so the leftovers are worth clearing. Anything removed that is needed later is pulled again.
- Installation
- Configuration
- Backup, required
- Email Providers, required
- DDNS, required on the Caddy path
- Countryblock (Caddy path)
- Fail2ban (Caddy path)
- Automatic Restarts
- Maintenance