Updates and backups
How releases work
Section titled “How releases work”Every AlphOne release is a git tag (vx.y.z) that publishes a container
image to ghcr.io/gopherium/alphone under three tags:
- the version, e.g.
:x.y.z - the exact commit, e.g.
:sha-5495093 :latest, which always points at the newest version
Migrations run automatically on container start, so updating is pulling a newer image and recreating the container.
Updating by hand
Section titled “Updating by hand”cd /srv/alphonedocker compose pull alphonedocker compose up -d alphoneRecreating the container starts serve, which applies the new version’s
migrations before it listens. Let that happen before the first account
change after an update, or run alphone migrate, which applies them
without starting the server, see Commands.
After an update from a release that did not keep command records yet,
the account commands that take -as change nothing until the
migrations ran. They stop with
the command records are missing, run migrate first.
Updating automatically
Section titled “Updating automatically”Any watcher that reacts to a republished :latest digest works. The
compose file in Install already carries labels
for What’s Up Docker (WUD):
wud.watch: "true"withwud.watch.digest: "true"onalphonewatches the:latestdigest and picks up each release.wud.watch: "false"onpostgresmakes sure the database is never auto-updated. A major PostgreSQL jump breaks its data directory.
On the WUD side, configure a ghcr registry (a public image needs no
token) and a trigger whose scope includes the alphone container. Start
with a notification-only trigger if you want to review updates before
they apply, then switch to auto once you trust the flow.
Updating from an older release
Section titled “Updating from an older release”Coming from one release back or older, the update changes what an
existing install sends and accepts. Read this before it reaches your
server, because a watcher on :latest applies it on its own.
- AlphOne refuses to deliver webhooks to internal addresses. A receiver
on your own network, such as n8n at
http://n8n:5678on the same Docker network or athttp://localhost:5678on the same machine, receives nothing until you list it, for example withALPHONE_WEBHOOK_ALLOWED_HOSTS=n8n:5678. Its subscription stays and looks active. The only signs are the warningrefusing a webhook delivery to an internal addressin the log and thelast_errorof its deliveries. See Webhooks. - Webhook deliveries ignore
HTTP_PROXYandHTTPS_PROXYand connect to the receiver directly. - A receiver that answers with a redirect, any
3xx, fails the delivery attempt. Subscribe the final address. - Disabling an account stops its webhooks.
- Only admins can create webhooks. A member’s session or token is
refused with
admin required, so an n8n trigger whose credential holds a member’s token stops activating until the credential holds an admin’s token. Webhooks that members created before keep firing, and nothing is deleted. Admins now see and can delete every webhook in their workspace, so review the list with thewebhooksquery after the update. - A browser write sent from a page at another origin is refused with
request_cross_origin. For a browser that does not sendSec-Fetch-Site, such as Safari before version 16.4, AlphOne compares itsOriginwith theHostheader. Behind a reverse proxy, the proxy has to pass the visitor’sHostthrough unchanged, or such a browser is refused on AlphOne’s own pages too.X-Forwarded-Hostis not read. See Cross-origin writes. - The command line was rebuilt. The image still starts
serveby itself, but acommand:or script of your own that ranalphonewith no command now only lists the commands, so it needsserve.createadminandgrantroleare refused under their old names, see Old names. - The rows and the contacts of an import come a page at a time. A read
of
importJob.rowsorimportJob.contactsthat names nolimitanswersALPHONE_GRAPH_PAGE_SIZEentries, 50 by default, instead of every one, and alimitaboveALPHONE_GRAPH_PAGE_CAPis refused. A workflow that reads the contacts of an import, such as the n8n node’s Get the contacts of an import, sees only the first page until it reads the rest, see Turning an import into a call list. - The WhatsApp conversation and message lists follow
ALPHONE_GRAPH_PAGE_SIZEandALPHONE_GRAPH_PAGE_CAPinstead of a fixed 50 and 200. account:enablerefuses an account that holds no role, or a role nothing declares any more, and so does its dry run. Give the account a declared role withaccount:rolefirst, see Changing an account.- Only accounts that may manage users open Users and Add User. A member who opens them lands on the home screen and finds their API tokens in the menu where Users was.
- The GraphQL API refuses an account write in WordPress’s two ways. A
write on an account whose role carries a capability the caller’s role
lacks answers the reason
user_not_editable. Giving a role the caller may not give, or enabling an account whose role nothing declares, answersrole_not_grantable. Earlier releases answeredrole_beyond_reachfor both. A program that reads those reasons needs updating, see roles. ALPHONE_PUBLIC_URLis now read without a mail relay too. On an install that sends no mail, a value AlphOne refuses now stopsserve, the account commands that take-as,migrate,seed -yesandaccount:create-admin, as the top of Configuration describes, andalphone checknames it. When it is set, the activation link AlphOne shows for you to pass on starts with it, so make sure it still names the address people reach AlphOne at. See Core.- AlphOne reads
ALPHONE_ENCRYPTION_KEY, the key that encrypts the secrets plugins keep for each workspace. It stays optional until a plugin stores a secret, but a malformed key stopsserve, see Encryption. - AlphOne no longer reads
ALPHONE_WHATSAPP_CREDENTIALS_KEY, so you can drop it from.env. A workspace’s own WhatsApp access token is now encrypted withALPHONE_ENCRYPTION_KEY, see WhatsApp plugin. A token stored under the old key no longer opens and has to be entered again. Until then a conversation on that stored number cannot reply, and the default workspace ignoresALPHONE_WHATSAPP_ACCESS_TOKENwhen the stored number is the one inALPHONE_WHATSAPP_PHONE_NUMBER_ID. - AlphOne keeps a
storageschema in its database for the files plugins keep. It creates the schema on its first start, and with the default settings you set nothing. It checks at start that it can reach the files and stops when it cannot. A setting of the S3 store withoutALPHONE_STORAGE_DRIVER=s3stops it too. The WhatsApp media stay in the plugin’s own table. See Files. - The first start after the update marks every contact address once, before AlphOne listens. It takes about 30 seconds for each million addresses, and their table takes twice its space until PostgreSQL vacuums it.
ALPHONE_CONTACT_MATCH_MAXis new and defaults to 100. A value AlphOne refuses stopsserve, see Contacts.- A workspace can hold many WhatsApp numbers, each with its own conversations,
so a customer who writes to two numbers has two conversations. A delivery is
stored only when its signature proves the number it names, see
More than one number. If the
default workspace held both
ALPHONE_WHATSAPP_PHONE_NUMBER_IDand a different stored number, its older conversations now read as the stored number, and a customer who writes to the number in the settings opens a new conversation. - AlphOne needs PostgreSQL 15 or newer. On an older server the first start stops at the WhatsApp numbers migration. The Compose file in Install runs PostgreSQL 18.
- The first start after the update rewrites every WhatsApp conversation of a workspace that stored its own number, before AlphOne listens. It takes about 12 seconds for each million conversations, and their table takes twice its space until PostgreSQL vacuums it.
ALPHONE_GRAPH_ANONYMOUS_ANSWER_MAX_BYTESunder 260 now stopsserveandalphone check, since the answer must hold what the sign-in screens read, see Graph limits.ALPHONE_TOAST_DURATIONnow times only the toasts with no button. A toast with a button, such as Undo, stays forALPHONE_TOAST_ACTION_DURATION, 10 seconds unless you set it, see Lists, toasts and formats.ALPHONE_PRIVACY_URLandALPHONE_TERMS_URLare new and optional. Set them to link your privacy policy and terms of service under the sign-in screens. A value AlphOne refuses stopsserve, see Core.ALPHONE_WHATSAPP_DELIVERY_ITEMS_MAX,ALPHONE_WHATSAPP_DELIVERY_NUMBERS_MAX,ALPHONE_MAX_PROCSandALPHONE_MEMORY_LIMIT_MBare new. Their defaults need nothing from you, and a value AlphOne refuses stopsserve, see WhatsApp plugin and Processors and memory.whatsAppConversation.messagesanswers the newest messages of a chat, still listed oldest first. Earlier releases answered the oldest ones, so a program that reads a long chat now gets its end and reads further back withbefore, see WhatsApp API.- A message from someone who hides their phone number is now stored under
the user ID Meta sends, such as
US.184467235. Earlier releases skipped it and still answered200, so those messages do not come back. An automation that reads a WhatsApp identity as a phone number needs to allow for a user ID, see Contacts. ALPHONE_DIALOG_WRITE_TIMEOUTis new and defaults to 60s. A dialog that waits on a save now stops waiting after that long and counts the save as failed, where earlier releases waited for good. A value AlphOne rejects stopsserveandalphone check, see Lists, toasts and formats.- A webhook delivery that was sent or failed for good keeps its payload,
the event body it carried, for
ALPHONE_WEBHOOK_PAYLOAD_AGE, 30 days unless you set it. The first start after the update clears the payload of every such delivery settled longer ago than that, and keeps the rest of the delivery. To keep older payloads, set a longer age before you update. A value AlphOne rejects stopsserve, see Webhooks. - The first start after the update builds an index over the webhook deliveries before AlphOne listens. It takes longer the more deliveries were sent or failed for good.
- The email plugin now keeps mail for your contacts. The first start
creates its
plugin_emailschema with empty tables. Mail arrives only throughalphone email:ingestand the demo data, see Stored mail. Once a workspace holds a mailbox, the menu shows an Email row that opens its inbox, see Email. Admins gainemail.manage_mailbox,email.delete_messagesandemail.delete_files, and API tokens gain anemailarea. A token that holds every area, as one made without-scopedoes, also reads the stored mail, and on an admin’s account it can delete mail too. - The email settings,
ALPHONE_PLUGIN_SCREENS_BUDGETandALPHONE_PLUGIN_HOOK_TIMED_FIRINGSare new and optional. A value AlphOne rejects, such asALPHONE_EMAIL_SYNC_WINDOWabove720h, stopsserveandalphone check, see Email plugin and Plugin hooks. Earlier releases ignore these settings, so afterdocker compose pull alphonerundocker compose run --rm alphone checkbeforedocker compose up -d alphone. - The GraphQL API rejects a query that asks the same field with the same
arguments under two names, with the reason
repeated_field. A program that asks one field under two aliases needs to ask it once, see One name for each field. - When the mail relay does not take an invitation, the server log now names the invitee’s address beside the relay’s error.
- A plugin route that panics now answers
500with AlphOne’s internal error, where earlier releases closed the connection. The server log gets oneplugin route panickedline that names the plugin, see Behavior worth knowing. - What’s Up Docker before 9.1.0 rebuilds the container from the old
container’s settings. Those name no command, because older images had
none, so the new version only lists the commands, exits 0 and
restarts in a loop. Update What’s Up Docker to 9.1.0 or later before
this release reaches your server, or switch its trigger to
notification only and update by hand as in
Updating by hand, which starts
serve.
Rolling back
Section titled “Rolling back”Pin the previous version and re-up:
image: ghcr.io/gopherium/alphone:x.y.z # the version to roll back to labels: wud.watch: "false" # pause auto-updates while pinneddocker compose up -d alphoneA release from before the command line was rebuilt serves when it runs
with no command, and refuses serve. Remove serve from any
command: or script you added before you pin such a release. It also
refuses every command in the Now column of
Old names, so a script that runs
one of them stops working.
One caution: rolling the app back does not roll the database back. Migrations only move forward, so if the newer version already migrated the schema, restore the matching backup instead of just pinning the older image.
A release from before the encryption key still starts on a database the
newer version migrated, but it cannot open the secrets plugins saved
since. It also needs ALPHONE_WHATSAPP_CREDENTIALS_KEY set again for the
WhatsApp tokens saved before the update. Restore the backup when you need
everything exactly as it was.
A release from before a workspace could hold many WhatsApp numbers also starts on a database the newer version migrated and reads everything, but every WhatsApp delivery and every number it stores fails. Restore the backup to go back to it. Rolling that migration back by hand keeps only the oldest number of each workspace.
A release from before AlphOne kept WhatsApp user IDs starts and reads
everything, since no migration came with them. It skips every new message
from someone who hides their phone number and still answers 200, so Meta
does not send it again. Its replies to such a person go out in to, where
Meta expects a phone number, so do not answer those conversations on it. A
page left open from the newer release cannot load a chat until it is
reloaded.
A release from before AlphOne kept mail also starts on a database the
newer version migrated. Its email plugin does nothing, so the stored mail
stays in the plugin_email schema with nothing to read it, and
email:ingest is gone. A token that holds only the email area reaches
nothing. The webhook payloads the newer release cleared do not come
back. A page left open from the newer release can fail to read the admin
settings and the mail, and can show an Email row whose inbox says
Mail could not be loaded. until it is reloaded.
If you ever roll a migration back by hand, know that the role each
account holds is the thing most easily lost. It lives in a role
column on the account row. The migration that added that column drops
it on the way down, and every promotion and demotion goes with it.
Save the roles first:
docker compose exec -T postgres psql -U alphone alphone -v ON_ERROR_STOP=1 \ -c "\\copy (SELECT id, role FROM auth.users) TO STDOUT WITH (FORMAT csv)" \ > roles.csv.part && mv roles.csv.part roles.csvThat keeps every role exactly as stored, including any role a plugin declared,
and CSV quoting handles whatever the values contain. ON_ERROR_STOP=1 matters
in both commands, because without it psql carries on after a failed statement
and leaves you an incomplete file that looks like a good one. The export writes
roles.csv.part and renames it only once the command succeeds, because your
shell creates the file it redirects into before psql even starts, so a failure
halfway through would otherwise hand you a truncated roles.csv in place of the
one you were counting on. Put the roles back
once the column exists again, reading the file on the machine you run the
command from:
docker compose exec -T postgres psql -U alphone alphone -v ON_ERROR_STOP=1 \ -c 'CREATE TEMP TABLE restored (id uuid PRIMARY KEY, role text NOT NULL)' \ -c "\\copy restored (id, role) FROM STDIN WITH (FORMAT csv)" \ -c 'UPDATE auth.users u SET role = r.role FROM restored r WHERE r.id = u.id' \ < roles.csvBoth commands stream through psql, so the file never has to exist inside the
container. Taking a full pg_dump before any rollback is simpler still, and it
is what the backup section below sets up anyway.
An account that ends up holding no role still works contacts and tasks,
because no field of the product asks for a capability. What it loses is
user management, so a rollback that strips every role can leave nobody
able to promote anyone back. account:grant-role gives a role to every
account holding none, and says how many it changed. It leaves the
accounts that already hold one alone, so running it twice changes
nothing the second time. Choose the role with care, because it goes to
every account holding none rather than to one you pick.
Like every command that changes an existing account, it acts as an
admin you name with -as, and it only shows what it would change until
you add -yes:
docker compose exec alphone /alphone \ account:grant-role -role member -as admin@example.comwould grant member to 2 accountsalphone: dry run, nothing changed, pass -yes to applyRun the same line with -yes at the end to give the role. The acting
account must be enabled, activated and hold a role that manages users,
such as admin. When nobody holds a role, no account can act, and the
command stops with
the account admin@example.com holds no role, so it lacks manage_users.
Create a new admin with account:create-admin, as in
Install,
and act as it:
docker compose exec alphone /alphone account:create-admin \ -email rescue@example.com -name "Rescue Admin" -role admindocker compose exec alphone /alphone \ account:grant-role -role member -as rescue@example.com -yesdocker compose exec alphone /alphone \ account:role admin@example.com admin -as rescue@example.com -yesThe last line gives one former admin the admin role back. Repeat it for
each of them. Every applied change is recorded, and account:records
lists who made it.
Backup scenario
Section titled “Backup scenario”A nightly pg_dump covers a single-server install. Save this as
/srv/alphone/backup.sh and make it executable:
#!/bin/sh# Dump the AlphOne database and prune dumps older than 14 days.set -eu
here="$(cd "$(dirname "$0")" && pwd)"dir="$here/backups"mkdir -p "$dir"
docker compose -f "$here/compose.yaml" exec -T postgres \ pg_dump -U alphone alphone | gzip >"$dir/alphone-$(date +%F-%H%M).sql.gz"
find "$dir" -name '*.sql.gz' -mtime +14 -deleteSchedule it daily:
( crontab -l 2>/dev/null; echo '0 3 * * * /srv/alphone/backup.sh' ) | crontab -Copy the backups/ directory somewhere off the server on your own
schedule. A backup that lives only next to the database it protects is
half a backup.
Back up ALPHONE_ENCRYPTION_KEY and ALPHONE_ENCRYPTION_PREVIOUS_KEYS
off the server as well, for example in a password manager. The dumps
hold the secrets plugins keep only in encrypted form, so a restore
without those keys opens none of them. Keep the keys apart from the
dumps, so that whoever gets a dump does not get the keys with it.
Backing up files
Section titled “Backing up files”With the postgres driver, the default, the files plugins keep live in
the storage schema of the database. The nightly pg_dump above holds
them, so it grows with them, and so does the time a dump and a restore
take. The files are stored without compression.
With the s3 driver, the database holds only the ids of the files and
the bucket holds the files. Back the bucket up too, on the same schedule
as the database, with the tools your store offers, such as versioning or
a copy to a second bucket. Restore the bucket beside the dump of the
same night. A database restored without its files points at files that
are gone.
A large file goes to an S3 store in parts. AlphOne aborts an upload that fails, but a server that stops in the middle of one, or an abort that fails, leaves parts in the bucket. The store keeps those parts, and bills for them, until a lifecycle rule aborts incomplete multipart uploads. Add such a rule to the bucket, for example one that aborts them after a day, where your store supports lifecycle rules.
With the postgres driver, AlphOne deletes an upload that never
finished on its own, once it is older than ALPHONE_STORAGE_SWEEP_AGE,
see Files.
Restoring
Section titled “Restoring”Stop the app, recreate the database, replay the dump, start the app:
cd /srv/alphonedocker compose stop alphonedocker compose exec -T postgres psql -U alphone -d postgres \ -c 'DROP DATABASE alphone' -c 'CREATE DATABASE alphone OWNER alphone'gunzip -c backups/alphone-<date>.sql.gz | \ docker compose exec -T postgres psql -U alphone alphonedocker compose start alphoneA restored database needs the same encryption keys it was saved under.
Set ALPHONE_ENCRYPTION_KEY and ALPHONE_ENCRYPTION_PREVIOUS_KEYS to
the keys in use when the dump was taken, or with a newer key, put every
older key in the previous list. A plugin that reads a secret no key
opens gets an error instead of the secret.
A dump can also go onto a new PostgreSQL server, such as a fresh container for a new PostgreSQL major version. The new server numbers its transactions from the start again. A plugin that follows the addresses contacts gain, see Contacts, saved a cursor that names the old server. The feed refuses that cursor, so the plugin reads every address again from the beginning. Handling an address twice does no harm. The first start on the new server also marks every address once, which takes about 30 seconds for each million addresses.