Skip to main content
The caddy storage command provides subcommands for working with Caddy’s storage, allowing you to export and import storage contents like TLS certificates and ACME data.
EXPERIMENTAL: This command may be changed or removed in future versions.

Usage

Description

Allows exporting and importing Caddy’s storage contents. The storage contains:
  • TLS certificates (from ACME or loaded files)
  • ACME account data (account keys, registration info)
  • ACME challenge data (for DNS and other challenges)
  • OCSP staples and other TLS-related data
This is useful for:
  • Migrating between storage backends
  • Backing up certificates and keys
  • Transferring data between servers
  • Switching storage configurations
When importing to or exporting from file_system storage (the default), the command should be run as the user that owns the associated root path.

Subcommands

export

Exports storage assets as a tarball.

import

Imports storage assets from a tarball.

Combining Export and Import

The two commands can be combined in a pipeline to transfer directly from one storage to another:
The - argument refers to stdout and stdin, respectively.

Export Flags

string
required
Input configuration file (required).The storage configuration will be extracted from this config.
string
required
Output path for the tarball (required).Use - for stdout (useful for piping).

Import Flags

string
required
Configuration file to load (required).The storage configuration will be extracted from this config.
string
required
Path to tarball to import (required).Use - for stdin (useful for piping).

Examples

Export to file

Creates backup.tar containing all storage assets.

Import from file

Restores storage assets from backup.tar.

Export to stdout

Writes tarball to stdout (useful for piping or compression).

Import from stdin

Compress backup

Restore from compressed backup

Transfer between servers

Migrate storage backends

Old config using file storage:
New config using different storage:
Migrate:

Backup before upgrade

Exit Codes

  • 0 - Success
  • 1 - Failed startup (invalid config or missing flags)
  • 2 - Failed quit (error during export/import)

What Gets Exported

The export includes all “terminal” keys from the storage:
  • Certificates - certificates/acme/.../*.crt
  • Private keys - certificates/acme/.../*.key
  • Account keys - acme/.../*.json
  • OCSP staples - Various cached data
  • Locks (if present at export time)
The exact structure depends on your storage backend and ACME usage.

Tarball Format

The export creates a standard tar archive:
Example contents:

Storage Backends

Caddy supports different storage backends:

File System (default)

Consul

Redis

S3

Migrating Between Storage Types

File System → Consul

Consul → File System

Caveats

  • Keys are removed during export if they’re deleted from storage while export is in progress (warning will be logged)
  • Permissions matter for file_system storage - run as the correct user
  • Storage must be configured in the config file for both export and import
  • Concurrent access during export may lead to inconsistent state

Best Practices

1. Stop Caddy during migration

2. Verify backup integrity

3. Regular backups

4. Encrypt sensitive backups

Troubleshooting

Permission errors

Run as the correct user or use sudo:

Storage not configured

If the config doesn’t specify storage, Caddy uses file_system storage with default paths. Make sure your config is complete.

Empty export

If export produces an empty or very small tarball:
  • Check that certificates exist in storage
  • Verify storage path is correct
  • Ensure ACME has issued certificates