hostfn rollback
Rollback to a previous deployment.
Usage
hostfn rollback [environment] [options]Arguments
| Argument | Description | Default |
|---|---|---|
environment | Environment to rollback | production |
Options
| Option | Description |
|---|---|
--to <timestamp> | Rollback to a specific backup by name |
Description
Restores a previous deployment from backup. HostFn creates a timestamped backup before each deployment, so you can easily go back to any recent version.
Interactive Mode
Without --to, the command lists available backups and lets you choose:
── Available Backups ──
1. 2024-01-15T10-30-00-000Z
2. 2024-01-14T15-20-00-000Z
3. 2024-01-13T09-00-00-000Z
? Select backup to restore: 1. 2024-01-15T10-30-00-000Z (latest)Rollback Process
- Fetches available backups from the server
- Restores the selected backup's
dist/directory - Reloads the PM2 process with the restored code
Examples
# Interactive rollback (select from list)
hostfn rollback production
# Rollback to specific backup
hostfn rollback production --to 2024-01-15T10-30-00-000Z
# Rollback staging
hostfn rollback stagingAutomatic Rollback
HostFn also performs automatic rollback during hostfn deploy when:
- The build step fails
- The health check fails after deployment
- PM2 fails to start the service
This happens transparently - no manual intervention needed.