prompts / vps-snapshot-restore.md
edit FILL IN & copy this prompt →857 words

Prompt: snapshot, restore, resize and re-disk an ird server

Have an agent run the backup lifecycle of an ird VPS: take and list snapshots, rebuild a server from one (that's also how you resize — a new server on a bigger tier from the snapshot), move the hostname over, attach a volume, retire old snapshots, and destroy the old server only after the new one is proven.

Needs: ird access (MCP server or the ird CLI, logged in — snapshots and volumes are CLI-only); an SSH key on the account; a shell with ssh; for the DNS move, the hostname's zone on ird DNS Costs: snapshots per GB-hour while kept (credits_prices → recurring.image-hourly); volumes per GB-hour (recurring.volume-hourly); a restored server bills its tier hourly from creation (recurring.vps-hourly), so two servers bill during the overlap Group: servers

Paste everything below the line into a fresh conversation. Fill in the FILL IN block first.


Task

Do OPERATION on SERVER below. Every step that bills or destroys is shown with its cost and id first and waits for my yes.

FILL IN

OPERATION:  resize                 # snapshot | restore | resize | attach-volume | prune-snapshots
SERVER:     app-1                  # name or id from vps_list
HOST:       app.example.ro         # hostname anchored at the server (blank = none)
ZONE:       example.ro             # its zone on ird DNS
NEW_TIER:   2x                     # for resize: tier id from vps_tiers
SNAPSHOT:   latest                 # for restore: a snapshot id from `ird vps snapshot images`, or latest
VOLUME:     data-1, 50             # for attach-volume: name, size GB — or an existing volume id
SSH_KEY:    laptop                 # name or id from `ird vps ssh-keys`
KEEP:       2                      # snapshots to keep per server when pruning

Non-negotiable rules

  1. Price before every billable step. Snapshot: size_gb from ird vps snapshot images × recurring.image-hourly × 730. Restored or resized server: vps_tiers hourly × 730. Volume: GB × recurring.volume-hourly × 730. State it, wait.
  2. Create once. vps_create blocks until provisioning finishes; never retry on a timeout — vps_list first; a second call is a second bill.
  3. Destroy only by named id, only after verification. vps_destroy is irreversible and takes the disk. I write the server id in chat; the new server has passed step E; the old one soaked powered off first.
  4. Snapshot deletion is permanent. Never delete the snapshot a restore is being verified from, nor the last one of a server that still exists.
  5. DNS: whole record sets. dns_set_record replaces the RRset; touch only HOST.

Steps

A. Inventory. vps_list → SERVER id, tier, ipv4, state. ird vps snapshot images → snapshots (id, size_gb, state, instance_id). ird vps volumes → volumes. vps_tiers → prices. dns_get_zone(ZONE) → HOST's record.

B. Snapshot (also the first step of restore and resize). ird vps snapshot SERVER <name> — name it <server>-<date>-<reason>. Stop writers first for a consistent image (docker compose stop, or vps_power(instance_id, operation="shutdown")), snapshot, restart. Poll ird vps snapshot images at most once a minute until available (ird vps activity: the create-image job's state).

C. Restore / resize = new server from the snapshot. vps_create(name=<SERVER>-new, tier_id=<NEW_TIER or same>, image_ref=<snapshot id>, ssh_key_ids=[id]) (CLI: ird vps create <name> --tier … --image <snapshot id> --ssh-key …). image_ref is documented as "system image id or snapshot id"; if the bare id is refused, use the create_ref from ird vps snapshot images --json (image:<id>). Pick a tier whose disk is at least the source server's (undocumented; suspect it first on a create error). Don't anchor with zone/subdomain while the old server holds HOST — move DNS in step D. An existing volume goes on with --volume <volume id> (CLI-only; not a vps_create parameter).

D. Move the hostname. After the new server passes E: dns_set_record(domain=ZONE, name="HOST.", type="A", data={address: <new ipv4>}) (CLI: ird dns set ZONE <short name> A <ip>). dig +short HOST = new IP. ird wrote the old server's anchor record at create and vps_destroy documents record removal only for one-click apps — after destroying it, dns_get_zone: HOST still at the new IP? Re-set if not.

E. Verify the new server. ssh <user>@<new ip>: services up (docker compose ps or systemctl), data present, app answers on the IP; then over https://HOST once DNS moved. Compare with the old server on its IP.

F. Attach a volume. ird vps volumes create <name> <size-gb> (CLI-only) → volume id. ird vps volumes has only create and delete — no attach/detach; the only attach is ird vps create --volume <id>, so plan it into step C. On the server: lsblk, mkfs.ext4 (only if empty), mount, /etc/fstab. ird vps volumes delete <volume-id> is permanent — only by named id.

G. Retire. Old server: vps_power(instance_id, operation="power-off") (CLI: ird vps power off SERVER), soak the agreed period (still billing while off), then, only on my written id, vps_destroy(instance_id) (CLI: ird vps destroy <id>). Then prune: keep the newest KEEP snapshots per instance_id, ird vps snapshot images delete <image-id> the rest one at a time, listing after each.

Deliverable

A before/after table: server ids, tiers, IPs, HOST target, snapshots kept (id, size, monthly cost), volumes, what was destroyed and when, and the monthly cost of what remains.

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/prompts.git