wheels db restore
Restore a database from a dump file.
Synopsis
Description
The wheels db restore
command imports a database dump file created by wheels db dump
or other database export tools. It can handle both plain SQL files and compressed dumps.
Arguments
file
Required. Path to the dump file to restore.
Options
--datasource=
Specify which datasource to restore to. If not provided, uses the default datasource.
--environment=
Specify the environment to use. Defaults to the current environment.
--clean
Drop existing database objects before restore.
--force
Skip confirmation prompts.
--compressed
Indicate the file is compressed. Auto-detected for .gz files.
Examples
Basic Restore
Restore Compressed Backup
Clean Restore
Drop existing objects first:
Force Restore
Skip confirmation in scripts:
Restore to Different Environment
Safety Features
Confirmation Required: Prompts before overwriting data
Production Warning: Extra warning for production environments
File Validation: Checks file exists before starting
Database-Specific Behavior
MySQL/MariaDB
Uses
mysql
clientHandles large files efficiently
Preserves character sets
PostgreSQL
Uses
psql
clientSupports custom formats from pg_dump
Handles permissions and ownership
SQL Server
Uses
sqlcmd
clientLimited support for complex backups
Best with SSMS for full restores
H2
Uses RUNSCRIPT command
Native support for compressed files
Fast for embedded databases
Common Workflows
Development Reset
Disaster Recovery
Environment Cloning
Important Warnings
Data Loss
Restoring overwrites existing data
Always backup current database first
Use
--clean
carefully
Version Compatibility
Ensure dump is from compatible database version
Check character set compatibility
Verify schema matches application version
Large Files
Monitor disk space during restore
Consider using
--compressed
dumpsMay need to adjust timeout settings
Pre-Restore Checklist
Backup current database
Verify dump file
Check disk space
Stop application (if needed)
Troubleshooting
"Access denied"
Check database user has CREATE/DROP permissions
Verify credentials in datasource
"File not found"
Check file path is correct
Use absolute paths for clarity
"Syntax error"
Verify dump file isn't corrupted
Check database version compatibility
Ensure correct database type
Restore Hangs
Large databases take time
Check database server resources
Monitor with
wheels db shell
in another terminal
Character Set Issues
Ensure database charset matches dump
Check connection encoding settings
Best Practices
Test restores regularly - Verify backups work
Document source - Note where dumps came from
Version control - Track schema version with dumps
Automate testing - Script restore verification
Secure dumps - Protect sensitive data in dumps
Recovery Scenarios
Partial Restore
If full restore fails:
Manual Recovery
Use database shell for control:
Related Commands
wheels db dump
- Create database dumpswheels db reset
- Alternative fresh startwheels db shell
- Manual restore controlwheels db status
- Verify after restore
Last updated
Was this helpful?