Skip to content

Delete Site Command

The delete command permanently removes a site and all its content from the Sites platform.

Overview

The delete command allows you to: - Permanently delete a site - Remove all site content and configuration - Free up space and resources

⚠️ Warning: Deletion is permanent and cannot be undone. All site content will be lost.

Global Flags

All commands support these global flags:

  • --debug, -d, --verbose - Show debug information
  • --insecure, -k - Skip TLS certificate verification (insecure)
  • --force, -f, -y, --yes - Force operations without prompting
  • --output, -o - Output format: json, yaml, or table (default: table)

Command

sitesctl delete

Permanently delete a site and all its content.

Usage:

sitesctl delete --space <space> --name <name>

Flags:

  • --space (required) - Site space identifier
  • --name (required) - Site name

Examples:

# Delete a site (will prompt for confirmation)
sitesctl delete --space myspace --name mysite

# Delete without confirmation prompt
sitesctl delete --space myspace --name mysite --force

# Delete with debug output
sitesctl delete --space myspace --name mysite --debug

# Delete with JSON output
sitesctl delete --space myspace --name mysite --output json

What it does: - Validates the site exists - Prompts for confirmation (unless --force is used) - Deletes all site content from storage - Removes the site configuration - Deprovisions web service - Removes the site from the Sites Hub

Confirmation Prompt:

Are you sure you want to continue? [y/N]:
Type y or yes to proceed with deletion.


Important Considerations

⚠️ Data Loss Warning

Deletion is permanent and irreversible: - All files and directories are removed - Site configuration is lost - Master tokens become invalid - The site URL becomes unavailable - There is no recovery option

Before Deleting

Create backups if needed:

# Download all site content
sitesctl site --space myspace --name mysite \
  content download --path / --recursive --archive zip

# Save site configuration
sitesctl list --space myspace --name mysite --output yaml > mysite-backup.yaml

Verify you're deleting the correct site:

# Check site details before deleting
sitesctl list --space myspace --name mysite

# Check site content
sitesctl site --space myspace --name mysite content list --path /

Permissions Required

You can delete a site if you are: - The site owner - Listed as an admin user for the site - Member of an admin group for the site - A hub administrator

If you don't have permission, you'll receive an authorization error.


Deletion Process

The deletion happens in these stages:

  1. Validation - Confirms the site exists and you have permission
  2. Confirmation - Prompts for user confirmation (unless --force)
  3. Content Removal - Deletes all files from storage
  4. Service Deprovisioning - Stops and removes the web service
  5. Hub Cleanup - Removes site from the Sites Hub database

Typical deletion time: A few seconds to a few minutes depending on content size.


Return Status

  • Success: Exit code 0, site deleted successfully
  • Authentication Error: Exit code 1, check your credentials
  • Permission Denied: Exit code 1, you don't have permission to delete this site
  • Site Not Found: Exit code 1, the specified site doesn't exist
  • API Error: Exit code 1, check connectivity and try again

Alternatives to Deletion

Consider these alternatives before deleting:

Archive Instead of Delete

Archive the site to disable it without losing data:

# Archive (disable) the site
sitesctl site --space myspace --name mysite update set:toggle

Archived sites: - No longer accessible via web - Retain all content and configuration - Can be unarchived later

Transfer Ownership

Transfer the site to another user:

sitesctl site --space myspace --name mysite \
  update set:owner --value newowner

Remove Content But Keep Site

Delete content while keeping the site structure:

# Delete all content
sitesctl site --space myspace --name mysite \
  content delete --path / --recursive


Recovery Options

There is no built-in recovery for deleted sites. However:

If You Have Backups

If you previously downloaded site content:

# Create a new site with the same name
sitesctl create --name mysite --space myspace --template iver

# Upload backed-up content
sitesctl site --space myspace --name mysite \
  content upload --source ./mysite-backup

Contact Support

In exceptional cases, contact ECMWF support immediately: - Sites may be recoverable for a short period after deletion - No guarantees - deletion is designed to be permanent - Recovery may take significant time


Scripting Examples

Safe Delete with Backup

#!/bin/bash
# Backup and delete a site

space="myspace"
name="mysite"
backup_dir="./backups/${space}-${name}-$(date +%Y%m%d)"

# Create backup directory
mkdir -p "$backup_dir"

# Download all content
echo "Creating backup..."
sitesctl site --space "$space" --name "$name" \
  content download --path / --recursive --archive zip

# Move downloaded content to backup directory
mv "${space}/${name}" "$backup_dir/"

# Save site configuration
sitesctl list --space "$space" --name "$name" --output yaml \
  > "$backup_dir/site-config.yaml"

echo "Backup complete: $backup_dir"

# Delete the site
echo "Deleting site..."
sitesctl delete --space "$space" --name "$name" --force

echo "Site deleted"

Batch Delete

#!/bin/bash
# Delete multiple sites

sites_to_delete=(
  "myspace:oldsite1"
  "myspace:oldsite2"
  "testspace:testsite"
)

for site in "${sites_to_delete[@]}"; do
  IFS=':' read -r space name <<< "$site"
  echo "Deleting ${space}/${name}..."
  sitesctl delete --space "$space" --name "$name" --force
done

Conditional Delete

#!/bin/bash
# Delete sites older than retention date

current_date=$(date +%s)

# Get all sites as JSON
sitesctl list --output json | jq -r '.[] | "\(.space):\(.name):\(.retention_date)"' | \
while IFS=':' read -r space name retention_date; do
  retention_epoch=$(date -d "$retention_date" +%s)

  if [ "$retention_epoch" -lt "$current_date" ]; then
    echo "Deleting expired site: ${space}/${name} (expired ${retention_date})"
    sitesctl delete --space "$space" --name "$name" --force
  fi
done

Troubleshooting

Permission Denied

Error: You don't have permission to delete this site
Solutions: - Verify you're the owner: sitesctl list --space X --name Y - Ask the owner to add you as an admin - Contact a hub administrator

Site Not Found

Error: Site not found
Solutions: - Verify the space and name are correct - Check spelling and case sensitivity - Use sitesctl list to confirm the site exists

Authentication Required

Error: Unauthorized
Solution: Login first with sitesctl auth login --username <username>

Deletion Fails

Error: Failed to delete site
Solutions: - Wait a moment and try again - Check your network connection - Try with --debug flag to see detailed error - Contact support if the problem persists


Best Practices

  1. Always create backups before deleting important sites
  2. Use --force carefully - double-check space/name before using it
  3. Prefer archiving for temporary disabling over deletion
  4. Document deletions in your team's procedures
  5. Clean up systematically rather than deleting many sites at once without verification
  6. Test deletion on test sites first if scripting batch deletions
  7. Communicate with team before deleting shared sites
  8. Verify site details with sitesctl list before the delete command

See Also