← Back to Blog
DevOpsTutorial

DevOps Automation: Deploy and Monitor with RAW CLI

You do not need Kubernetes, Terraform, or a DevOps team to automate your infrastructure. The RAW CLI handles deployments, monitoring, backups, and multi-server management from your terminal or CI pipeline. Here is how to set it up.

What RAW CLI Does

The RAW CLI is a single binary that manages your entire server lifecycle:

  • Deploy: Provision new servers in 13 seconds
  • SSH: Connect to any server without managing keys manually
  • Execute: Run commands across multiple servers simultaneously
  • Monitor: Check server health, resource usage, and uptime
  • Scale: Add or remove servers with a single command

Install

# Install via npm (works everywhere Node runs)
npm install -g rawhq

# Or use npx for one-off commands
npx rawhq deploy

Automated Deployments

Most deployment tools add complexity. RAW keeps it simple: push code, run a command, your app is live.

Basic Deploy Workflow

# Deploy a new server
raw deploy --name production --plan raw-4

# SSH in and set up your app (first time only)
raw ssh production

# For subsequent deploys, run commands remotely
raw exec production -- "cd /var/www/app && git pull && npm install && pm2 restart all"

Zero-Downtime Deploy Script

Save this as deploy.sh in your project root:

#!/bin/bash
# Zero-downtime deploy script for RAW
set -e

SERVER="production"
APP_DIR="/var/www/app"

echo "Pulling latest code..."
raw exec $SERVER -- "cd $APP_DIR && git fetch origin main"

echo "Installing dependencies..."
raw exec $SERVER -- "cd $APP_DIR && git reset --hard origin/main && npm ci --production"

echo "Running migrations..."
raw exec $SERVER -- "cd $APP_DIR && npm run migrate"

echo "Restarting with zero downtime..."
raw exec $SERVER -- "cd $APP_DIR && pm2 reload ecosystem.config.js"

echo "Verifying health..."
raw exec $SERVER -- "curl -sf http://localhost:3000/health || exit 1"

echo "Deploy complete."

This script pulls code, installs dependencies, runs database migrations, and does a rolling restart — all without dropping a single request. PM2’s reload command starts new processes before killing old ones.

CI/CD Integration

Connect RAW to your existing CI/CD pipeline. Here are configurations for the most popular providers.

GitHub Actions

# .github/workflows/deploy.yml
name: Deploy to RAW
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install RAW CLI
        run: npm install -g rawhq

      - name: Deploy
        env:
          RAW_API_KEY: ${ secrets.RAW_API_KEY }
        run: |
          raw exec production -- "cd /var/www/app \
            && git pull origin main \
            && npm ci --production \
            && npm run migrate \
            && pm2 reload all"

      - name: Health check
        run: |
          sleep 5
          curl -sf https://yourapp.com/health

GitLab CI

# .gitlab-ci.yml
deploy:
  stage: deploy
  only:
    - main
  script:
    - npm install -g rawhq
    - raw exec production -- "cd /var/www/app
        && git pull origin main
        && npm ci --production
        && npm run migrate
        && pm2 reload all"
    - curl -sf https://yourapp.com/health

Bitbucket Pipelines

# bitbucket-pipelines.yml
pipelines:
  branches:
    main:
      - step:
          name: Deploy to RAW
          script:
            - npm install -g rawhq
            - raw exec production -- "cd /var/www/app
                && git pull origin main
                && npm ci --production
                && pm2 reload all"

All three follow the same pattern: install the CLI, authenticate with your API key, execute the deploy command on your server. No Docker images to build, no container registries, no orchestration layers.

Health Monitoring

Monitoring does not require Datadog ($15/host/mo) or New Relic ($25/host/mo). RAW CLI combined with simple scripts covers 90% of monitoring needs.

Built-in Health Checks

# Check all servers
raw status

# Detailed info on a specific server
raw info production

# Check resource usage
raw exec production -- "free -h && df -h && uptime"

Automated Health Monitor Script

Save as monitor.sh and run via cron every 5 minutes:

#!/bin/bash
# Simple health monitor for RAW servers
SERVERS="production staging"
WEBHOOK="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"

for SERVER in $SERVERS; do
  # Check if server responds
  if ! raw exec $SERVER -- "echo ok" > /dev/null 2>&1; then
    curl -X POST $WEBHOOK -H "Content-type: application/json" \
      -d "{\"text\":\"ALERT: $SERVER is unreachable\"}"
    continue
  fi

  # Check disk usage
  DISK_USAGE=$(raw exec $SERVER -- "df / --output=pcent | tail -1 | tr -d ' %'")
  if [ "$DISK_USAGE" -gt 85 ]; then
    curl -X POST $WEBHOOK -H "Content-type: application/json" \
      -d "{\"text\":\"WARNING: $SERVER disk usage is high\"}"
  fi

  # Check memory usage
  MEM_USAGE=$(raw exec $SERVER -- "free | awk '/Mem/{printf(\"%d\", \$3/\$2*100)}'")
  if [ "$MEM_USAGE" -gt 90 ]; then
    curl -X POST $WEBHOOK -H "Content-type: application/json" \
      -d "{\"text\":\"WARNING: $SERVER memory usage is high\"}"
  fi

  # Check app health endpoint
  if ! raw exec $SERVER -- "curl -sf http://localhost:3000/health" > /dev/null 2>&1; then
    curl -X POST $WEBHOOK -H "Content-type: application/json" \
      -d "{\"text\":\"ALERT: $SERVER app health check failed\"}"
  fi
done

Add to crontab:

# Run health checks every 5 minutes
*/5 * * * * /path/to/monitor.sh

This gives you server reachability, disk and memory alerts, and application health checks — all sent to Slack. Total cost: $0.

Backup Automation

Backups are non-negotiable. Here is a battle-tested backup script that handles databases, application files, and retention.

Automated Backup Script

#!/bin/bash
# Daily backup script for RAW servers
set -e

SERVER="production"
BACKUP_DIR="/backups"
RETENTION_DAYS=30
DATE=$(date +%Y-%m-%d)

echo "Starting backup for $DATE..."

# Create backup directory
raw exec $SERVER -- "mkdir -p $BACKUP_DIR/$DATE"

# Backup PostgreSQL
raw exec $SERVER -- "pg_dump -U postgres -Fc your_db \
  > $BACKUP_DIR/$DATE/database.dump"

# Backup application files
raw exec $SERVER -- "tar czf $BACKUP_DIR/$DATE/app.tar.gz \
  /var/www/app --exclude=node_modules --exclude=.git"

# Backup Nginx config
raw exec $SERVER -- "tar czf $BACKUP_DIR/$DATE/nginx.tar.gz /etc/nginx"

# Backup environment files
raw exec $SERVER -- "cp /var/www/app/.env $BACKUP_DIR/$DATE/env.backup"

# Remove backups older than retention period
raw exec $SERVER -- "find $BACKUP_DIR -maxdepth 1 -type d \
  -mtime +$RETENTION_DAYS -exec rm -rf {} +"

# Optional: sync to a second RAW server
# raw exec $SERVER -- "rsync -az $BACKUP_DIR/$DATE/ \
#   backup-server:$BACKUP_DIR/$DATE/"

echo "Backup complete: $DATE"

Schedule with cron for daily execution at 3 AM:

# Daily backups at 3 AM
0 3 * * * /path/to/backup.sh >> /var/log/backup.log 2>&1

Restore from Backup

# Restore database
raw exec production -- "pg_restore -U postgres -d your_db \
  --clean $BACKUP_DIR/2026-04-05/database.dump"

# Restore application files
raw exec production -- "tar xzf $BACKUP_DIR/2026-04-05/app.tar.gz -C /"

Multi-Server Management

When your setup grows beyond a single server, RAW CLI makes managing multiple servers feel like managing one.

Server Naming Convention

# Deploy with descriptive names
raw deploy --name web-1 --plan raw-4
raw deploy --name web-2 --plan raw-4
raw deploy --name db-1 --plan raw-8
raw deploy --name staging --plan raw-2

Execute Across Multiple Servers

# Update all web servers
for server in web-1 web-2; do
  raw exec $server -- "cd /var/www/app && git pull && npm ci && pm2 reload all"
done

# Check status of all servers
raw status

# Run security updates everywhere
for server in web-1 web-2 db-1 staging; do
  raw exec $server -- "apt update && apt upgrade -y"
done

Rolling Deploys

#!/bin/bash
# Rolling deploy across web servers
SERVERS="web-1 web-2"

for SERVER in $SERVERS; do
  echo "Deploying to $SERVER..."

  # Pull and restart
  raw exec $SERVER -- "cd /var/www/app \
    && git pull origin main \
    && npm ci --production \
    && pm2 reload all"

  # Wait for health check
  sleep 10
  if ! raw exec $SERVER -- "curl -sf http://localhost:3000/health"; then
    echo "FAILED: $SERVER health check. Stopping rollout."
    exit 1
  fi

  echo "$SERVER deployed successfully."
done

echo "Rolling deploy complete."

This deploys to one server at a time, verifies health before moving to the next, and stops the rollout if any server fails. No orchestration tool needed.

Putting It All Together

A complete DevOps setup with RAW looks like this:

ComponentTraditionalRAW CLI
ProvisioningTerraform + cloud consoleraw deploy (13s)
CI/CDDocker + registry + K8sGitHub Actions + raw exec
MonitoringDatadog ($15/host/mo)Bash script + Slack ($0)
BackupsAWS Backup ($$$)Cron + pg_dump ($0)
Multi-serverAnsible / Puppetraw exec + bash loops
Setup timeDays to weeks30 minutes
Monthly cost$100–500+ in tooling$0 (CLI is free)

The entire stack — deploys, CI/CD, monitoring, backups, multi-server management — runs through one CLI with zero additional tooling costs. No YAML sprawl, no Docker registries, no infrastructure-as-code state files.

Get Started

# Install and deploy your first server
npm install -g rawhq
raw deploy

13 seconds to a production server. 30 minutes to a fully automated DevOps pipeline. 7-day free trial, no credit card.