Backups and restores
Store snapshots of your servers in S3 or a volume, and restore them.
Backups involve three resources: a BackupRepo says where snapshots are stored, a Backup takes a snapshot of a server, and a Restore puts one back. Backups and restores need a server with storage.
Backup repositories
A BackupRepo is either an S3-compatible bucket or a volume in the same namespace.
apiVersion: kobblestone.io/v1alpha1kind: BackupRepometadata: name: offsitespec: type: S3 s3: endpoint: https://s3.example.com bucket: minecraft-backups credentialsSecretRef: name: offsite-credentials # keys: access-key and secret-keyapiVersion: kobblestone.io/v1alpha1kind: BackupRepometadata: name: localspec: type: PersistentVolumeClaim persistentVolumeClaim: name: minecraft-backups # created if it does not exist size: 50GiA volume that does not support ReadWriteMany can only be used by one backup, restore or cleanup at a time. Others wait until it is free.
Taking a backup
A Backup is a one-time request for a snapshot:
apiVersion: kobblestone.io/v1alpha1kind: Backupmetadata: name: survival-before-updatespec: repoRef: name: offsite targetRef: name: survivalWhat happens depends on the server:
- Running server: an online backup. It coordinates with the server over RCON, so the world is saved consistently while players keep playing. This needs RCON enabled.
- Stopped server: an offline backup. The server is kept stopped until the backup has finished.
The snapshot contains the server’s data and configuration. Files that are downloaded again on startup, such as the server .jar, are left out.
Backups and restores of the same server never run at the same time. They queue up and run one after another, in the order they were created. While a backup waits, its status.message says why.
Kobblestone has no built-in schedule yet. To back up regularly, create Backup objects from a CronJob or your deployment tooling, with a unique name each time.
What happens when you delete a Backup
spec.retainPolicy decides what happens with the snapshot when the Backup object is deleted:
| Policy | Behavior |
|---|---|
Retain (default) | The snapshot stays in the repository. |
Delete | Kobblestone tries to delete the snapshot, but does not wait for the result. |
RequireDelete | The Backup object is only removed once the snapshot is deleted. Failed attempts are retried. |
Restoring a backup
A restore replaces a server’s data with a snapshot. Stop the server first: the restore waits until the server is in phase Stopped and keeps it stopped while it runs.
kubectl patch server survival --type merge -p '{"spec":{"state":"Stopped"}}'apiVersion: kobblestone.io/v1alpha1kind: Restoremetadata: name: survival-rollbackspec: backupRef: name: survival-before-update targetRef: name: survival existingDataPolicy: OverwriteexistingDataPolicy decides what happens if the server already has data. The default, Fail, refuses to touch a server that is not empty. Overwrite replaces the existing data.
Warning: With
Overwrite, the server’s current data is deleted. If you might still need it, take a backup of the stopped server first.
Once the restore is Completed, set the server’s spec.state back to Running.
Phases
Backups and Restores report Pending, Running, Completed or Failed in status.phase, with details in status.message. Each one runs as a Job. If you delete the Job before it has finished, the operation is marked as Failed. With spec.job.activeDeadlineSeconds you can set a time limit.