Bring the wiki in line with v3.0.0 and the major image tags
Read every page against v3.0.0 and master (bitwarden_gcloud #114-#117).
- Installation and the disk-loss recovery check out the newest release
after cloning, and Cloud Shell Setup downloads that release's scripts,
so new installs follow releases the way Updating Your Deployment does.
- Updating Your Deployment looks the newest release up instead of
hard-coding v3.0.0, and prunes images a tag change left behind.
- Container counts include watchtower: seven on Caddy, four on a tunnel.
- Instance Metadata lists the twelve files the cloud-config writes now,
including make-private.sh and the home-directory links.
- Migrating to a Data Disk sends a deployment still on pre-v3 code to
the update, since the migration alone leaves its broken watchtower.
- Operations says which tag each image follows and fixes a relative link
that does not resolve on the wiki.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ArPBUq2nqe2bkxtqPzAqiF
8d6d7a0
Follow releases instead of master, and run watchtower by default
Updating Your Deployment now checks out the newest release tag and points
at its release notes; following master stays available in a note.
watchtower runs by default again from v3.0.0 (bitwarden_gcloud #114), so
Operations, the old-deployment migration and the tunnel page say so, and
WATCHTOWER_MONITOR_ONLY=true is the way to turn updating off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ArPBUpcDUvDERXUP8nSCqB
3d9ecc7
Installation: put the Compose version sample under its command
26f4b15
Installation: chmod 600 the new .env (follows #102)
f293f4d
Move reasoning into numbered notes on the maintenance pages
825399a
Add a path for deployments older than the backup service
Refs dadatuputi/bitwarden_gcloud#110. Covers the update a pre-mid-2023 deployment needs before migrating (manual backup, shim, stale .env values, watchtower), scopes Updating Your Deployment to migrated instances, and summarises what the migration script does.
50f19db
Going back to Caddy: rewrite from a live run
Thirteen findings from following the section on a real deployment from a
Mac rather than Cloud Shell. The section now checks the gcloud project,
connects as the user who owns the deployment (gcloud compute ssh logs
in as the local username, and sed and git fail otherwise), repeats the
supervisor check instead of pointing back to Step 2, keeps a copy of
.env, has the operator create the A record by hand as DNS only (ddns
only runs once Caddy does, so waiting for it never ends), explains what
the certificate step looks like when an old certificate is reused,
uses --tail instead of -f, tests from outside with --resolve while the
local resolver still holds the empty answer, notes that COS drops
rather than refuses on unpublished ports, and ends with the tunnel
delete and reserving the address.
34bc155
Make Caddy the default path and say the tunnel is not free
Installation leads with Caddy in the intro note, the prerequisites, both
comparison tables (with a cost row) and the Caddy-first ordering of Steps
5, 9 and 10, and gains a section on what the free tier includes for
network traffic. Switching to a Cloudflare Tunnel opens with the cost and
links Going back to Caddy. Countryblock says it is part of what keeps the
Caddy path free; Fail2ban no longer calls the tunnel the default. DDNS
says to keep a Cloudflare record DNS-only, since proxying it is billed
the same way as the tunnel. Home and the sidebar match.
0c4bef4
Say that watchtower stops when you pull
Operations explains the change and the changelog notes it, but neither upgrade
path did: not the README section written to tell existing deployments what
changes, nor the update procedure itself. A reader following either kept a
deployment whose image updates had silently stopped.
7347081
Refresh the utility scripts before regenerating the cloud-config
Step 5 sent the reader to ~/bwgc without saying that those scripts are a copy
downloaded earlier. Running the old copy regenerates the configuration already
on the instance, add-metadata reports 'No change requested; skipping update', and
the update appears to succeed while changing nothing.
Also documents the Permission denied on bitwarden/backups/.gitignore, which is
written by containers running as root, and how to restore it.
991ab47
Add the missing update procedure
Nothing documented how to adopt repository changes on a running vault. git pull
appeared once in the whole wiki, incidentally, on the tunnel page. Installation
builds, Migrating moves data, Upgrading replaces the OS, and none of them covers
pulling code onto an instance that stays where it is.
The page covers the ownership check first, because git refuses to operate on a
repository owned by another login and gcloud takes the login from the client
machine, so this is the common failure. Then backup, stop the supervisor, pull,
reapply metadata, in-guest reboot, verify, and roll back.
6a22303
Describe how the deployment symlink is created
Instances with the current cloud-config create it in every home present at boot
and on first interactive login elsewhere, so the page no longer says not to rely
on it. It states the one case that is still uncovered: a login that has never
opened a shell, in a home created since the last boot.
a3bd925
Make the deployment path unambiguous
Three forms were in use across seven pages: an absolute path, a bare
~/bitwarden_gcloud, and an ls of both locations piped to head. Which one worked
depended on who was connecting, because gcloud takes the ssh login name from the
local machine rather than the Google account, so the same instance presents
different home directories to a laptop and to Cloud Shell.
Maintenance pages now use /mnt/disks/bwgc/bitwarden_gcloud throughout. Cloud
Shell Setup states that once, with the cause and a command that shows which
login you are using.
Pre-migration deployments have no canonical path, since they live in whichever
home ran the install. The migration page now confirms that gcloud lands in the
right one before its first command instead of assuming it.
Installation still creates the ~/bitwarden_gcloud symlink and now says it is a
convenience local to one login rather than something other pages depend on.
ae69dcb
Install the compose helper before the page first uses it
Step 4 sourced ~/.bwgc-compose.sh, and the command that creates that file was 85
lines further down, at the end of the page. A reader following the steps in
order got "No such file or directory" and then "docker-compose: command not
found". The helper only exists after Installation Step 8 or a migration run,
neither of which a legacy deployment arriving here for maintenance has done.
The remaining commands hardcoded ~/bitwarden_gcloud, which is a symlink that
does not exist on every deployment and is lost whenever the home directory is
rebuilt, as this page notes. They now use the same lookup as the rest of the
wiki.
f983fa8
Add an Operations page, moved out of the README
The README carried 276 lines of runbook: secrets, image updates, restore, OS
updates, resource limits, intrusion blocking, SSH, log growth, status checks and
backup verification. That is reference material for people who already run a
deployment, on the page newcomers land on first.
It moves here unchanged apart from the venue preamble, which the README stated
and this page now states once at the top.
6fb20df
Correct the Caddy downgrade, verified on a live instance
Three defects found by checking each command before running it. cloudflared
tunnel delete refuses while the tunnel has active connections, which the page
did not mention though it calls it immediately after removing the container.
Removing COMPOSE_FILE and TUNNEL_TOKEN was prose only, on a host whose editor is
vi. And the firewall rules were written in a different syntax from Installation
Step 6, without the source range, so the two would drift.
The rules were also presented as always needed. A default project carries
default-allow-http and default-allow-https targeting the same tags, so the page
now checks first, which is what Installation Step 6 already did.
Verified on a throwaway instance: the tunnel stack served HTTPS 200, the
documented teardown emptied the host and flipped compose from three services to
six, restoring the tags took port 80 from closed to Caddy's 308 redirect, and
the supervisor ran a full cycle afterwards without resurrecting cloudflared.
Certificate issuance was not verified, because that needs an A record and this
session has tunnel credentials only; the failure observed was the one the page
predicts when the CNAME is left in place.
f8348ab
Fix defects found by the third audit round, second sweep
Instance-Metadata and Automatic-Restarts both told the reader to apply new
metadata with gcloud compute instances reset, immediately after writing it.
migrate-to-data-disk.sh carries a comment explaining why it does not: reset is a
power cycle that neither flushes page cache nor unmounts, so a file written
seconds earlier reaches the disk truncated and the fsck in bootcmd zero-fills the
tail. That corrupted a vault's .env on a real run. Both pages now use an in-guest
reboot, which is graceful and keeps the ephemeral address.
The migration page put "set every .env value before you bring the stack up"
between the command that brings the stack up and the command that sets the key,
so a reader working top to bottom did exactly what the warning forbids. The
blocks are now in the order the warning describes.
Also: the recovery container-removal list omitted cloudflared and watchtower, so
it left a name conflict on the tunnel path; two anchors on the upgrade page were
left over from headings that used to contain a dash; removal of the timer was
documented as regenerating the config without it, which nothing supports;
removing user-data has different consequences depending on BWGC_RESTART_POLICY
and now says so; and the README documented a verification command that reports
an rclone error on the shipped configuration.
f64101a
Fix defects found by the third audit round
The deployment-shape test was wrong again, in a new way. systemd's list verbs
exit 0 whether or not the pattern matches, so "list-unit-files X >/dev/null &&
echo migrated" always reported migrated. It now tests for the unit file, which
fails closed, and the labels say what is actually being tested: a Caddy install
from the current Installation page carries the supervisor without ever having
been migrated.
The Step 7 bypass added last round told a reader with an existing filesystem to
skip to Step 10. Step 8 is what creates the docker-compose shim and the home
symlink, so Step 10's first command would have been command not found. The
bypass now restores both.
Nothing on the Installation page ever set BWGC_RESTART_POLICY, though the page
builds exactly the shape that needs it: a data disk plus the bwgc cloud-config.
Only migrate-to-data-disk.sh set it, and Installation only ever calls that with
--print-cloud-config. Without it Docker starts the stack about twenty seconds
before cloud-init mounts the disk, which is the race the design exists to avoid,
and it surfaces on the first reboot rather than during the install.
Also: .env is now created in Step 8, because the supervisor can fire between the
clone and Step 9 and Docker would create the missing bind source as a directory;
releasing a reserved address needs the address detached first; and going back to
Caddy restored port 80 without ever restoring DNS.
018c536
Fix defects found by the second audit round
The deployment-shape test added last round was wrong. It branched on which path
"ls -d /mnt/... ~/... | head -1" returned, but ls sorts its operands and /home
sorts before /mnt, so on a migrated deployment, which has both because the
migration leaves a symlink, it always returned the home path. Every migrated
reader was told they had no data disk and skipped stopping the supervisor, which
is the failure that section exists to prevent. It now branches on whether the
unit exists.
The recovery section told a reader whose old data disk survived to reattach it
and run the migration against it. That rsyncs the restored copy over the
surviving vault with --delete. It now says to mount it read-only and look first.
.env.template shipped BACKUP_EMAIL_NOTIFY=true with every SMTP setting commented
out. backup.sh runs under set -u and reads SMTP_SECURITY as soon as
notifications are on, so a default install exited with "unbound variable" before
writing any backup, and the weekly check that exists to catch stopped backups
died at the same line.
Also: aborting the upgrade at the delete prompt left a stopped instance and a
detached disk with no documented recovery; removing the user-data key was
described as harmless when it carries the disk mount; the mail test on
Email-Providers could not succeed on a healthy deployment; and the tunnel page
claimed a downtime window that did not match its own step order.
a297dac
Fix defects introduced by the previous round of fixes
The mkfs warning added last round told a reader with an existing filesystem to
skip the format and run the rest of the step. Following that led into Step 8's
git clone and Step 9's cp .env.template .env, which overwrite the deployment and
the .env the warning had just protected. That branch now sends them to Step 10
instead, and runs nothing.
Adding the DNS record step to the Caddy path moved the reader to Cloud Shell and
never moved them back, so chmod 600 .env and docker-compose up -d landed on the
wrong machine. The tunnel branch had been given that handling and the Caddy
branch had not.
Reconciling the country lists produced a claim that countryblock protects a
reader from egress charges. It does not run on the tunnel path, which is the
default, and that claim was the third line of the page.
Also: nothing created ~/bitwarden_gcloud, which four commands on Cloud Shell
Setup depend on; the tag-removal remediation had no command; the Caddy path had
no way to tell whether the certificate was issued; and Step 0 listed the
prerequisites for one path only.
1e3aace
Give the reverse tunnel procedure the same machine markers as the forward one
Going back opened with a cd on the instance, but Step 6 leaves the reader in
Cloud Shell, and the gcloud block in the middle needed an exit before it and a
reconnect after. The supervisor restart is now conditional in both directions
rather than only the forward one.
21e395f
Fix ten blockers found by a cold-reader audit
The migration page said aborting was harmless. Past the Proceed? prompt it is
not: the reboot question arrives after the stack is down, the restart policy is
set to no and the metadata is replaced, and answering no there leaves the vault
stopped with the script refusing to re-run. It now says so and gives the reboot
that recovers it.
Registration was never mentioned anywhere in the wiki, while SIGNUPS_ALLOWED
ships true. Step 11 now closes it.
The restore command omitted RESTORE_FORCE, which the backup container requires
because it has no Docker socket, so the documented recovery could not run. It
now carries the flag, a way to find a real filename, and a success criterion.
The tunnel switch pointed DNS at a tunnel two steps before that tunnel started,
and omitted --overwrite-dns, which is required to replace the A record every
reader of that page has. The steps are reordered and the page states that the
vault is down while you work. Its systemctl commands are now marked as applying
only to migrated deployments, which is the shape the same page says may not
apply.
Also: the Caddy path never created its DNS record; mkfs.ext4 -F carried no
warning on a page a reader may re-run with a populated disk; Automatic Restarts
named a file the script does not write; fail2ban, countryblock and ddns did not
say they are inactive on the default path; and a four-command paste block set a
backup encryption key published in this wiki.
Register: 81 em dashes and 14 bold lead-in paragraph openings removed, verdict
headings replaced with plain nouns.
a9db6f7
Say what "Going back" goes back to
The section was headed "Going back" with no object, and opened by referring to
"the forward direction" -- a term the page never uses anywhere else and never
defines. A reader skimming headings could not tell what the section undoes, and
a reader who opened it was told to apply rules from a direction that had not
been named.
It is now "Going back to Caddy", with a first line saying what the outcome is,
and the reference points at Steps 3 and 4 by number.
e635bd8
Apply the supervisor stop to the reverse direction too
A third tester proved the Step 3 fix works: they idled seven minutes forty
seconds mid-procedure, across what would have been the timer's fire, and stayed
at zero containers. Switching forward now works exactly as written.
Going back did not, because the fix was only applied in one direction. Step 6
restarts bwgc-supervise.timer, and Going back then runs down against a
deployment where it is armed. Reproduced with timestamps: down emptied the host,
the supervisor fired four minutes later and brought the tunnel stack back, and
continuing literally produced seven containers with cloudflared surviving as an
orphan and the hostname still answering 200 -- the precise symptom the section's
own warning describes, reached by following its ordering correctly.
Going back now stops the supervisor first, checks docker ps -a for a surviving
cloudflared, removes it directly if compose can no longer see it, and starts the
timer again at the end.
That is the third symmetric pair in this work where the forward fix landed and
the mirror did not, after the compose ordering and the earlier cd path.
Installation: cloud-init starts the stack itself once a deployment exists, so a
fast reader can collide with it and get a container-name conflict from their own
docker-compose up -d. Re-running completes; Step 10 now says so. Step 9 claimed
the cloudflared commands were the only ones on the page not run in Cloud Shell,
which is untrue of Steps 7, 8, 9 and 10, all of which run on the instance. And
Step 11 sent the reader to the Backup page to set BACKUP_SCHEDULE, a variable
that appears nowhere on it, when .env.template already ships both that and
BACKUP_EMAIL_NOTIFY uncommented.
dc64f98
Stop the supervise timer from undoing the switch, and fix the verification venue
A second tester followed both pages. The tunnel install works and the reordered
switch produced exactly three containers on a literal first pass. These are what
it found beyond that.
bwgc-supervise.timer runs compose up -d every five minutes on every instance
this wiki builds. The switching page had the reader run down and then go to
another machine to fetch the tunnel token, so the timer put the entire Caddy
stack back while they were away, and the next step produced seven containers --
the exact state the reordering was meant to prevent, reached by following the
order correctly. The page now stops the timer first and starts it again at the
end, which the disaster-recovery page already did and this one should have
copied.
That step's recovery advice was also wrong in the same way "Going back" warns
about: it said to remove COMPOSE_FILE and run down, which reads the base file
set and strands cloudflared. It now removes the four containers directly, since
compose can no longer see them.
Both verification curls ran in a shell that has no gcloud. Installation puts the
reader on the instance at Step 7 and never brings them back; Switching opens an
ssh session and never closes it. Container-Optimized OS ships no gcloud, and
INSTANCE and ZONE are empty there, so both commands failed twice over. Both now
say where to run them.
Step 11 told the reader to run install-cos-update-reboot.sh from a path that
resolves in neither place, to install a timer the metadata from Step 5 has
already installed. It now verifies instead, and says what the script is for.
Step 5's command block carried the Caddy-only tags, so the copy button handed
the tunnel reader -- the default path -- a command that opens 80 and 443. The
two commands are separate now, tunnel first.
Also: the step-difference lists still named Step 5 in both, because an earlier
batch edit was discarded when a later assertion in the same batch failed; the
troubleshooting branch for "three containers but the address answers" describes
a state that cannot occur, since nothing listens on 80 once proxy is gone; a
failed bwgc.service on a new instance is normal until Step 8 and now says so;
grep -A3 stopped short of the lines its sample showed; and the page required a
git pull it never gave a command for.
2ffd149
Fix the switching order, which produced the state its own sentence forbade
A tester followed both new pages. The tunnel install passed every check on the
first attempt. Switching an existing deployment did not, for two reasons, and
both were in the ordering.
Step 3 had you add COMPOSE_FILE to .env and then run down. Compose only stops
what the file set it reads selects, and by then proxy, ddns, countryblock and
fail2ban are parked in a never-enabled profile, so down skipped all four. The
result was seven containers on an e2-micro, with the page's own sentence -- "so
the four services the tunnel retires are actually stopped rather than left
running alongside it" -- promising the opposite of what its steps produced.
Worse, the verification step then misread the symptom. Port 80 answered because
orphaned Caddy still held it, and the page said "If it answers, the firewall
rules are still in place". Removing the tags makes the symptom vanish either
way, so the wrong explanation was confirmed by the outcome while four containers
kept running, one of them a fail2ban whose bans no longer enforce anything.
Stopping comes first now, and the check lists container count before tags and
says why that order matters.
Going back had the identical defect mirrored: removing COMPOSE_FILE before down
left cloudflared running and still serving the hostname the reader believed they
had just closed.
The page also assumed the deployment was in the home directory. A deployment
built by the current Installation page is on the data disk, so its very first cd
failed. It now resolves both locations, as Cloud Shell Setup already did.
Installation: the step-difference lists named Step 5 in both; the overview said
seven containers when a Caddy deployment runs six, because watchtower is opt-in
and does not start; chmod 600 sat inside the Caddy subsection, so a tunnel
reader never restricted a file that now holds their tunnel token; and the tags
note said the tags select Step 6's rules, when a default project already carries
default-allow-http and default-allow-https targeting exactly those tags -- so
dropping the tags is what closes the ports, not skipping Step 6.
Also: the tunnel commands are the only ones on the page that do not run in Cloud
Shell, which is now stated; head -12 never reached the lines its sample showed;
and the compose version sample pinned a number that the floating docker:cli
image had already moved past.
e355108
Branch installation on how the vault is reached, tunnel first
A Cloudflare Tunnel dials out, so the instance opens no ports, holds no
certificate and has no DNS record of its own. That retires proxy, ddns,
countryblock and fail2ban: seven containers become three. It is now the default
path on the Installation page, with Caddy documented alongside rather than
beneath it.
The page branches rather than forking: steps 0 to 5, 7, 8 and 11 are shared, and
the four that differ say so where they differ. Creating the tunnel lives inside
Step 9 because its token is what you put in .env, which also avoids renumbering
eleven steps.
Only EMAIL turned out to be genuinely Caddy-specific -- it is the ACME contact
and its sole consumer is tls {$EMAIL} in the Caddyfile. SMTP and the backup mail
settings apply on both paths and are documented as required on both: vaultwarden
sends invitations and password hints, and the backup container sends failure
notices and the weekly status check that catches a backup which has stopped
running.
Switching to a Cloudflare Tunnel covers an existing deployment moving across,
including what to remove afterwards and what replaces fail2ban, whose iptables
bans match nothing once traffic arrives through a tunnel.
The trade is stated on both pages: Cloudflare terminates TLS at its edge. Vault
contents are encrypted on the client, so what is exposed is metadata and
authentication traffic, and Caddy remains supported for anyone who would rather
not have a third party in that position.
8080038
Correct the last details a full clean run turned up
The final verification run completed every phase and both recoveries with no
blocker. These are the remainder.
Step 4's settings table had its separator below the first data row, so GitHub
promoted BACKUP_ENCRYPTION_KEY and its whole description into the header and the
two settings read as different kinds of thing. It has a header row now.
Step 5's sample plan omitted the line the script prints directly above it,
naming the data disk it read from the instance.
On the recovery path, reusing the same disk name makes the regenerated
configuration identical to what is already set, so gcloud answers "No change
requested; skipping update" immediately after a keystroke the page has just
called mandatory. The page now says that is the correct outcome.
Step 2's listing also contains instance-<name>.json, a configuration dump the
upgrade saves, which is often the newest entry and is not a backup.
5cb3002
Fix the recovery path's last blocker and make it findable
A tester ran the recovery end to end twice, encrypted and unencrypted, and both
produced a working vault that survived a hard reset. Step 6's rewrite holds:
the restored stack runs as compose project bwgc-restore while Step 6 removes
bitwarden_gcloud_*, so the cleanup provably cannot touch it. These are the
remaining defects.
Step 7 issued gcloud commands without leaving the instance shell that Step 3 put
the reader in. Container-Optimized OS does not ship gcloud -- a fact Cloud Shell
Setup states in its first line -- and INSTANCE and ZONE are Cloud Shell session
variables that are empty there. It now says to exit first.
Step 7 also hardcoded bwgc-data, the default, on the one path where the reader
may well have used --disk-name, and where the old disk often still exists
because the loss was a detach rather than a deletion. The name is a variable
now, carried into the migration handoff, with both cases called out.
That handoff raises a prompt the migration page never lists: because the
instance still has metadata naming the lost disk, the script asks whether to
replace it. Declining aborts and leaves the instance configured to mount a disk
that is gone, so the next reboot has no vault. The prompt is documented where it
occurs, and the migration page's blanket "pressing Enter is safe" is qualified
for the one path where it is not.
Step 6 told the reader never to delete ~/bwgc-restore. Step 7 then makes it a
stale copy, and a second recovery fails because its first command clones into
that path. Cleanup is now Step 8, gated on the vault working from the data disk.
Finally, the section was unreachable: nothing in the sidebar, Home or the Backup
page linked to a recovery procedure buried in a page about upgrading the OS.
All three now point at it.
e47f935
Stop the recovery procedure from deleting the vault it just recovered
A tester ran the disaster-recovery path end to end, twice. It destroyed the
recovery both times, and could not reach that point without an undocumented
workaround first.
Step 6 was written as tidying -- "the restore leaves a compose project of its
own behind" -- and told the reader to run "docker-compose -p bwgc-restore down
-v" and "rm -rf ~/bwgc-restore". But bwgc-restore IS the recovered deployment;
the step before adopts it and says to log in and check your entries. Following
the page left no containers, a dangling symlink, and the uploaded archives
deleted, while the old project's network and cert volume survived untouched.
Adoption is now its own step, it says in bold not to delete the directory, and
only the old project's leftovers are removed.
Step 4's first command could not run at all. Stopping bwgc.service does not free
the container names: its ExecStop stops containers without removing them, so all
six keep their names and the restore project collides on "/proxy". The stop step
now removes them, and explains why that destroys nothing.
Step 4 also started vaultwarden as a compose dependency and then asserted
RESTORE_FORCE=true, which claims the vault is stopped. It was not. The Backup
page warns in bold that restoring while vaultwarden holds the database open
risks losing writes. It now uses --no-deps so the assertion is true.
The restore does copy .env out, to bitwarden/.env.restored, which is simpler
than the manual extraction the page described and was documented as impossible.
Both are now covered, and the procedure ends by getting the deployment back onto
a data disk rather than leaving it on the boot disk.
Cloud Shell Setup Step 4 said the scripts refuse to run without an encryption
key twelve lines above saying neither setting stops them. The refusal claim is
gone and both configurations are described.
a0e65c8