History Commands

v0.4.8Updated for ɳSelf v0.4.8

The nself history command provides an audit trail of all ɳSelf operations, deployments, and changes. Track deployments, migrations, rollbacks, and commands with search and export functionality.

Audit Trail Features

  • Command History: Track all CLI commands executed
  • Deployment Log: Full deployment history with status
  • Change Tracking: Configuration and schema changes
  • Search and Export: Find and export history records

Viewing History

nself history

View command history (default command).

nself history [options]

# Options:
#   -n, --limit <n>      Number of entries (default: 20)
#   --since <duration>   Time range (e.g., 24h, 7d)
#   --type <type>        command, deploy, config, db
#   --json               Output as JSON

# Example output:
# ID     TIME                 TYPE      COMMAND
# 156    2026-01-23 10:30     command   nself deploy staging
# 155    2026-01-23 10:25     command   nself build
# 154    2026-01-23 10:20     config    .env updated
# 153    2026-01-23 09:45     db        migration applied

nself history show

Show details of a specific history entry.

nself history show <id>

# Example
nself history show 156

# Output:
# History Entry #156
# ==================
# Type: command
# Command: nself deploy staging
# Time: 2026-01-23 10:30:15
# Duration: 45s
# Status: success
# User: admin
#
# Details:
#   Environment: staging
#   Files synced: 24
#   Services restarted: 8

Deployment History

nself history deploy

View deployment history.

nself history deploy [environment] [options]

# Options:
#   -n, --limit <n>      Number of entries
#   --status <status>    Filter by status (success, failed, rollback)

# Examples
nself history deploy                    # All deployments
nself history deploy staging            # Staging only
nself history deploy prod --limit 10    # Last 10 production

# Output:
# ID    TIME                 ENV       STATUS    DURATION
# 45    2026-01-23 10:30     staging   success   45s
# 44    2026-01-22 18:00     prod      success   62s
# 43    2026-01-22 15:30     staging   failed    12s
# 42    2026-01-22 14:00     staging   success   38s

nself history deploy show

Show deployment details.

nself history deploy show <id>

# Output:
# Deployment #45
# ==============
# Environment: staging
# Time: 2026-01-23 10:30:15
# Duration: 45 seconds
# Status: success
# Deployed by: admin
#
# Changes:
#   - docker-compose.yml updated
#   - nginx/conf.d/default.conf updated
#   - .env updated
#
# Services:
#   - postgres: no change
#   - hasura: restarted
#   - auth: restarted
#   - nginx: reloaded
#
# Commit: abc123f

Configuration History

nself history config

View configuration change history.

nself history config [options]

# Output:
# TIME                 FILE          CHANGES
# 2026-01-23 10:20     .env          3 variables changed
# 2026-01-22 18:00     .env          MONITORING_ENABLED added
# 2026-01-22 14:00     server.json   host updated

nself history config diff

Show configuration diff between entries.

nself history config diff <id1> <id2>

# Example
nself history config diff 150 155

# Output:
# Configuration Changes (150 → 155)
# =================================
# + MONITORING_ENABLED=true
# + GRAFANA_ADMIN_PASSWORD=****
# - DEBUG=true
# ~ LOG_LEVEL: info → warning

Database History

nself history db

View database operation history.

nself history db [options]

# Options:
#   --type <type>        migration, backup, restore, seed

# Output:
# TIME                 TYPE        DETAILS
# 2026-01-23 09:45     migration   20260123_add_orders applied
# 2026-01-22 23:00     backup      backup_20260122.sql (2.3GB)
# 2026-01-22 14:00     seed        staging data loaded
# 2026-01-21 10:00     migration   20260121_users_table applied

Search and Filter

nself history search

Search through history.

nself history search <query> [options]

# Examples
nself history search "deploy"
nself history search "prod" --type deploy
nself history search "migration" --since 7d

nself history filter

Filter history by criteria.

nself history filter [options]

# Options:
#   --type <type>        command, deploy, config, db
#   --status <status>    success, failed
#   --since <duration>   Time range
#   --user <user>        Filter by user

# Example
nself history filter --type deploy --status failed --since 30d

Rollback

nself history rollback

Rollback to a previous state.

nself history rollback <id> [options]

# Options:
#   --config-only        Only rollback configuration
#   --dry-run            Preview rollback
#   --force              Skip confirmation

# Examples
nself history rollback 150                    # Full rollback
nself history rollback 150 --dry-run          # Preview
nself history rollback 150 --config-only      # Config only

Export and Reporting

nself history export

Export history for reporting.

nself history export [options]

# Options:
#   --format <fmt>       json, csv, markdown
#   --output <file>      Output file
#   --since <duration>   Time range

# Example
nself history export --format csv --output history.csv --since 30d

nself history report

Generate history report.

nself history report [options]

# Options:
#   --period <period>    daily, weekly, monthly
#   --format <fmt>       html, markdown

# Example
nself history report --period weekly --format html

History Storage

History is stored in .ɳSelf/history/:

.nself/history/
├── commands.log      # Command history
├── deployments.log   # Deployment records
├── config/           # Config snapshots
│   ├── 2026-01-23_10-20.env
│   └── 2026-01-22_18-00.env
└── db/               # Database operation logs

Environment Variables

VariableDescriptionDefault
NSELF_HISTORY_RETENTIONDays to keep history90
NSELF_HISTORY_ENABLEDEnable history trackingtrue

Next Steps