Skip to content
Claude edited this page Nov 6, 2026 · 18 revisions

Every gcloud command in this wiki runs from Google Cloud Shell, which has it installed and authenticated.¹

This page is the setup those tasks share. Work through it once per session, then go back to whichever page sent you here.

Task Needs
Installation Steps 1–2 and 5
Migrating to a Data Disk All of it
Upgrading Container-Optimized OS All of it
Automatic Restarts Steps 1–3 and 5

Where the deployment lives

/mnt/disks/bwgc/bitwarden_gcloud, on every deployment built or migrated by this wiki. Commands on these pages use that path. A ~/bitwarden_gcloud symlink also points at it.²

Check which login you are and where your link is:

gcloud compute ssh $INSTANCE --zone $ZONE --command 'whoami; ls -d /home/*/bitwarden_gcloud 2>/dev/null'

Deployments that predate the data disk are at ~/bitwarden_gcloud instead, and Migrating to a Data Disk moves them.


Step 1. Open Cloud Shell

Go to shell.cloud.google.com and wait for the prompt.³


Step 2. Set your project

List your projects:

gcloud projects list
PROJECT_ID              NAME                 PROJECT_NUMBER   ...
my-vault-project        My Vault Project     123456789012     ...

Set yours, substituting your own PROJECT_ID:⁴

gcloud config set project my-vault-project

Confirm:

gcloud config get-value project

Installing for the first time? Stop here and go back to Installation. You have no instance yet.


Step 3. Point at your instance

gcloud compute instances list
NAME       ZONE           MACHINE_TYPE  ...  STATUS
bitwarden  us-central1-a  e2-micro       ...  RUNNING

Export the two values that command showed:⁵

export INSTANCE=bitwarden
export ZONE=us-central1-a

Step 4. Record your backup encryption key

gcloud compute ssh $INSTANCE --zone $ZONE --command 'sudo grep "^BACKUP_ENCRYPTION_KEY=" /mnt/disks/bwgc/bitwarden_gcloud/.env'

Copy the value somewhere you can still reach when this vault is gone, and not into this vault.⁶ On a deployment not yet migrated, use ~/bitwarden_gcloud/.env instead.

If that prints nothing, no key is set. That is supported, and the maintenance scripts will take an unencrypted backup and tell you so.⁷ To set one, put it in .env, install the compose helper, and bring the stack up:⁸

gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && sh utilities/install-alias.sh'
gcloud compute ssh $INSTANCE --zone $ZONE --command '. ~/.bwgc-compose.sh; cd /mnt/disks/bwgc/bitwarden_gcloud && docker-compose up -d'

Keep the . ~/.bwgc-compose.sh prefix. Running compose commands yourself explains why.


Step 5. Download the scripts

Find the newest release, then download its scripts:

export TAG=$(git ls-remote --tags --refs --sort=-v:refname https://github.com/dadatuputi/bitwarden_gcloud 'v*' | head -1 | sed 's|.*/||')
echo "$TAG"
mkdir -p ~/bwgc && 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

echo should print a release such as v3.0.0. If it printed a blank line, the lookup failed and nothing new was downloaded; run the block again. Files from an earlier session would still be listed below, so check echo rather than the listing.¹²

Check you have all four:⁹

ls ~/bwgc
install-cos-update-reboot.sh
lib-bwgc-cloudinit.sh
migrate-to-data-disk.sh
upgrade-cos.sh

These delete instances and create disks. Read them before running them:

less migrate-to-data-disk.sh

Running compose commands yourself

Logged in interactively, docker-compose is already there:

gcloud compute ssh $INSTANCE --zone $ZONE
cd /mnt/disks/bwgc/bitwarden_gcloud
docker-compose ps

Sent as a one-liner, source the helper in the command:

gcloud compute ssh $INSTANCE --zone $ZONE --command '. ~/.bwgc-compose.sh; cd /mnt/disks/bwgc/bitwarden_gcloud && docker-compose ps'

Leaving out the . prefix gives docker-compose: command not found. That is not a broken install.¹⁰

If ~/.bwgc-compose.sh is missing, reinstall it:¹¹

gcloud compute ssh $INSTANCE --zone $ZONE --command 'cd /mnt/disks/bwgc/bitwarden_gcloud && sh utilities/install-alias.sh'

Done

Go back to the page that sent you here:

Your session variables (INSTANCE, ZONE) last as long as this Cloud Shell tab. If it times out, re-run Step 3.

Notes

1. Container-Optimized OS does not ship gcloud, so none of these commands can run on the instance itself.

2. gcloud compute ssh takes the login name from your local machine rather than from your Google account, so connecting from a laptop whose user is alice and from Cloud Shell as alice.example lands in two different home directories on the same instance. Instances carrying the current cloud-config create the symlink in every home present at boot, and in any other home the first time someone logs in interactively. A login that has never opened a shell, on a home created after the last boot, has no link until it does. Commands on these pages use the absolute path, so this only matters if you type ~/bitwarden_gcloud yourself.

3. Cloud Shell's home directory persists between sessions, so anything you download here is still around next time.

4. A fresh Cloud Shell has no project selected, and every gcloud compute command needs one. Without it they fail with The required property [project] is not currently set. gcloud adds columns to the listing between releases, so yours may show more; only PROJECT_ID matters.

5. Every command on the maintenance pages uses these two variables, so nothing there needs editing.

6. The maintenance scripts take a backup and download it into this Cloud Shell session. With BACKUP_ENCRYPTION_KEY set, that archive is encrypted with it and cannot be opened without it.

7. Two settings decide what the backup holds, and neither stops the scripts from running. The scripts print both before taking the backup. BACKUP_ENCRYPTION_KEY unset gives a plain tar.gz with no .aes256 suffix: still a usable backup with nothing to record, but treat the file as a secret. BACKUP_ENV=true, which .env.template ships, puts your .env inside the archive so a restore can recover your settings; false leaves the archive holding your vault data only.

8. Container-Optimized OS ships no compose binary, and a deployment built before this helper existed has an alias instead, which ssh --command cannot use. Installing the helper is safe to run more than once.

9. These are the two maintenance scripts, the shared library they source, and the timer installer that Automatic Restarts uses, and they must sit in the same directory. curl -f writes nothing when a file is missing, so a short listing means the download failed rather than that a file is empty.

10. gcloud compute ssh --command runs a non-interactive shell, which reads no startup files at all. Container-Optimized OS has nowhere to put a docker-compose executable that would help: every directory on PATH is on the read-only root, and /home and /var are both mounted noexec. So the project installs a shell function, and a one-liner has to source it.

11. The file lives on the instance rather than the data disk, so anything that rebuilds the home directory loses it. The upgrade puts it back on the replacement itself, so this is for repairs rather than part of the documented upgrade path.

12. The scripts come from the same release that Installation and Updating Your Deployment check out on the instance, so the cloud-config they generate matches the deployment it starts. master can carry unreleased changes.

Clone this wiki locally