VolumeBackup
Source:
src/Railway/VolumeBackup.ts
A Railway.VolumeBackup is a snapshot of a volume instance. Create it
next to a Railway.Volume. Railway backups run as workflows —
Alchemy waits for workflowStatus then reads the backup list.
Restore is destructive to the volume instance; use
restoreVolumeBackup. Point-in-time restore forks a new
Postgres service via restoreVolumePITR.
Create a backup
Section titled “Create a backup”Pass the Volume. Alchemy generates a unique name. The volume should be attached to a Service — Railway only backups mounted volumes.
const site = yield* Railway.Project("Site");const api = yield* Railway.Service("Api", { project: site, image: "hashicorp/http-echo",});const data = yield* Railway.Volume("Data", { project: site, mountPath: "/data", service: api,});const snap = yield* Railway.VolumeBackup("Nightly", { volume: data });Omit name for an ownership-stamped name. Pass one to label the
snapshot in the dashboard.
const snap = yield* Railway.VolumeBackup("Nightly", { volume: data, name: "pre-migrate",});Lock to drop the expiration. One-way.
const snap = yield* Railway.VolumeBackup("Nightly", { volume: data, lock: true,});Schedules
Section titled “Schedules”schedules is volume-instance state, not per-snapshot. Set it on
one VolumeBackup that owns the instance.
const snap = yield* Railway.VolumeBackup("Nightly", { volume: data, schedules: ["DAILY", "WEEKLY"],});Restore
Section titled “Restore”Restore is not a reconciler step. Call restoreVolumeBackup
(destructive to the instance) or restoreVolumePITR (forks a
new Postgres service).
yield* Railway.restoreVolumeBackup({ volumeInstanceId: snap.volumeInstanceId, volumeInstanceBackupId: snap.volumeInstanceBackupId,});Module-scope declarations
Section titled “Module-scope declarations”Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");export const Data = Railway.Volume("Data", { project: Site, mountPath: "/data",});export const Nightly = Railway.VolumeBackup("Nightly", { volume: Data,});