Backups
Copy a box's disk, or a volume's, to the kvbox cloud, encrypted, by hand or every night, and put it back later.
A backup is a copy of a box's disk and its own variables, stored encrypted on a backup store: a host other than the box's when there is one, else the box's own. A box made under a location is backed up only to a store inside it, or the backup fails. Unlike a snapshot it holds no memory: putting it back boots the box fresh from that disk. A box's volumes are not part of its backup: a volume is backed up on its own, the same way.
kvbox vm backup create <box> # start a backup; it runs in the background
kvbox vm backup create <box> --wait # stay until it is stored
kvbox vm backup ls # every box's backups, newest first
kvbox vm backup ls <box> # one box's backups
kvbox vm backup restore <box> <id> # the disk becomes the backup's
kvbox new <name> --from-backup <id> # a new box from a backup, a removed box's too
kvbox vm backup rm <box> <id> # delete a backup for goodTaking one
A running box keeps running: it is frozen for the moment its disk is cloned on the host, then the clone is uploaded in the background. Just before that, the box writes out everything it still holds in memory for its disk and holds new writes back until the clone is made (a second or two; programs keep running), so what is stored is a clean disk as it was at that instant. A box on an image from before base v0.19.0 cannot do that: its backup is the disk as it was at that instant, like after a power cut, which the box's filesystem recovers from on its own.
The disk is cut into 4 MB pieces. Empty pieces are skipped, and a piece the same store already holds from an earlier backup of any of your boxes is not sent again, so the first backup uploads what the box holds and the next ones only what changed. kvbox vm backup ls shows both: data is what the backup holds, uploaded what it added.
A backup you start costs $1, charged once it is ready; one that fails costs nothing. It shows under backups in kvbox usage, and an account without credit cannot start one. The price is the same for a box, a volume, a managed database and object storage. A nightly backup you turn on costs $0.10 a night; a database's nightly backup is included in the database's price.
A box can take 2 backups in any 24 hours, and one at a time; a failed backup does not count. A box you remove and create again under the same name keeps its count.
Each piece is encrypted on the host before it leaves, with a key that belongs to your account (or org). The storage only ever sees encrypted pieces.
Restoring
restore replaces the box's disk and its own variables with the backup's; anything written since is gone, so it asks first (-y skips the question). The backup is downloaded next to the box's disk while the box keeps running, then the box is stopped, the disk swapped in and the box started again. A stopped box stays stopped. A hibernated box is refused: its saved memory belongs to the disk it has now, so wake it or stop it first. A box whose disk is bigger than when the backup was taken keeps its size; one whose disk is smaller is refused (kvbox vm rescale <box> --disk first). One restore of a box runs at a time.
If the box's disk was made bigger after the backup, it keeps its new size.
A backup belongs to the box it was taken of, not to its name. If you remove a box and later make a new one with the same name, the old box's backups are listed as the removed box's (ls marks them removed), and restore refuses to put them into the new box.
A new box from a backup
kvbox vm backup ls deeptutor # a removed box's backups are still listed by its name
kvbox new deeptutor --from-backup <id> # a new box on that disk--from-backup makes a new box whose disk is the backup's. It boots on the same image and image version the backup was taken on (the image's current version once the host no longer has that one, as kvbox vm update would), with the box's own variables as they were, and the backup's size unless you give --size. A size whose disk is smaller than the backup's is refused, and a box that had a custom vCPU and memory needs --size. The disk is downloaded before the box first boots, so the command waits for it. Any name works: the removed box's own, or another one beside a box that is still there. This is how a removed box comes back, and how you make a copy of a box as it was at a backup. In the web app, a removed box's backup has New box… on the Backups page.
Deleting one
rm deletes a backup for good: it disappears from every list at once and can no longer be restored. It asks first (-y skips the question). A backup that is still running cannot be deleted; delete it once it has finished. The backups of a box you removed are still listed, and rm deletes them the same way. In an org, a member deletes only the backups they took; the org's owner and admins delete any.
A backup is kept 30 days; older ones are deleted the same way, on their own.
The space it took is freed about a day later, and only the pieces no other backup of yours uses: a piece shared with an earlier or later backup stays. A deleted backup still counts toward the box's 2 backups in 24 hours.
Volumes
A volume is backed up like a box, by the same commands under kvbox volume backup:
kvbox volume backup create <volume> # start a backup; it runs in the background
kvbox volume backup create <volume> --wait # stay until it is stored
kvbox volume backup ls # every volume's backups, newest first
kvbox volume backup ls <volume> # one volume's backups
kvbox volume backup restore <volume> <id> # the volume's data becomes the backup's
kvbox volume backup rm <volume> <id> # delete a backup for goodEverything above holds for a volume too: the box that holds it is frozen only for the moment the volume's disk is cloned, the pieces are encrypted with the same key and shared with your boxes' backups, and a volume can take 2 backups in any 24 hours, counted apart from a box of the same name.
What is stored is the volume as it was at one instant, written out and held still by the box the same way (base v0.19.0 and later; before, like after a power cut). A database on it (Postgres, Redis with its append-only file) comes back from such a copy the way it comes back from a crash: it replays its log when it next starts. No dump is needed.
restore replaces the volume's data with the backup's and asks first. The backup is downloaded next to the volume while the box that holds it keeps running on the old data; then that box is stopped, the volume swapped and the box started again. A detached volume, or one on a stopped box, is just swapped. A volume on a hibernated box is refused: wake or stop the box first. A volume that was grown since the backup keeps its size; a backup of a larger volume is refused (kvbox volume grow first).
A managed database's storage has its own commands, by the same means: kvbox pg backup and kvbox redis backup (see Postgres and Redis), and so has object storage: kvbox bucket backup, the whole storage at once, with what a restore does to buckets and keys made or removed since (see Object storage). A container registry has kvbox registry backup: every image in it, restored into the same registry with the password it has now (see Container registry). A managed database is also backed up every night on its own (kvbox pg backup schedule). A Kubernetes cluster is too: kvbox k8s backup backs up what the cluster knows (its deployments, services, secrets and config, not what pods keep on a node's disk), every night and by hand, and restores it into the same cluster.
Nightly backups
A box, a volume and your object storage can be backed up on their own once a day. It is a switch, off until you turn it on:
kvbox vm backup schedule <box> --on # back the box up every night
kvbox vm backup schedule <box> --at 3 # at 03:00 UTC (turns it on)
kvbox vm backup schedule <box> # shows when, and how the last one went
kvbox vm backup schedule <box> --off # stop; the hour is kept for next time
kvbox volume backup schedule <volume> --on # the same for a volume
kvbox bucket backup schedule --on # and for your object storage
kvbox registry backup schedule --on # and for your container registry--on picks a night hour for it, between 00:00 and 05:00 UTC. A nightly backup costs $0.10, charged once it is ready (a night that fails costs nothing; about $3 a month); it does not count toward the 2 backups in 24 hours you may take yourself, and is kept 30 days like any other; ls shows it as taken by schedule. It is skipped while the account has no credit, and when a backup of the same thing is already running. If the host is not answering, it is tried again within the hour, for up to six hours.
The switch belongs to the box or volume itself: removing it removes its schedule, and a new one of the same name starts with none. A box's nightly backup does not include its volumes; turn theirs on as well.
A managed database is different in that its nightly backup is on from the moment it is created, and included in its price.