Skip to content

rollback

Restore the environment’s state file from the newest state.<env>.json.bak.<timestamp> written before a save. Rollback is a local state-file operation — it never calls a cloud API and never destroys leftover resources.

Terminal window
kyku rollback [options]
Flag Default Description
-e, --env <environment> default Environment workspace
--state-dir <dir> .kyku State directory
--yes false Skip confirmation prompt
Terminal window
# Preview orphans, then confirm
kyku rollback
# After a failed apply, restore the pre-apply backup without prompting
kyku rollback --yes
# Production workspace
kyku rollback --env=prod --yes
  • Picks the newest .bak.<timestamp> for the environment. If none exists, the command exits 1 with a clear error.
  • Writes the backup over the live state file without bumping serial, so the restored file matches the backup.
  • Resources present in the discarded state but absent from the backup are printed as ORPHAN with their provider ID. They stay in the cloud unless the failed apply used --rollback-destroy. Import them with kyku import or delete them in the cloud console.
  • Confirmation is required unless --yes is set.
  • There is no automatic rollback on apply failure, no multi-step undo, and no remote-backend rollback.

kyku apply copies the current state to a timestamped backup before mutating it. If the apply fails partway, kyku rollback puts the state file back to that pre-apply backup. Cloud resources created during the failed apply become orphans.

Code Meaning
0 Restored, or the user aborted the confirmation
1 No backup, invalid backup, or other error