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.
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
- 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:- 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
backup.tar containing all storage assets.
Import from file
backup.tar.
Export to stdout
Import from stdin
Compress backup
Restore from compressed backup
Transfer between servers
Migrate storage backends
Old config using file storage:Backup before upgrade
Exit Codes
0- Success1- 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)
Tarball Format
The export creates a standard tar archive:Storage Backends
Caddy supports different storage backends:File System (default)
Consul
Redis
S3
Migrating Between Storage Types
File System → Consul
Consul → File System
Caveats
Best Practices
1. Stop Caddy during migration
2. Verify backup integrity
3. Regular backups
4. Encrypt sensitive backups
Troubleshooting
Permission errors
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
Related Commands
caddy run- Start Caddy with storage configcaddy validate- Validate storage configuration