Backup & Restore
DBCode’s Backup & Restore feature allows you to create backups of your databases and restore them when needed. This feature leverages the native backup tools provided by each database engine, offering database-specific options for backup format and content.
Overview
The Backup & Restore feature provides:
- Flexible backup options: Full backups, schema-only, or data-only
- Format choices: Database-specific formats optimized for each engine
- Easy restoration: One-click restore with optional flags
- Progress tracking: Real-time feedback during backup and restore operations
Creating a Backup
-
Navigate to your database In the DB Explorer pane, locate the database you want to backup.
-
Open the backup menu Right-click on the database name and select Backup Database….
-
Configure backup options Choose your preferred backup type and format (options vary by database engine).
-
Select save location Choose where to save the backup file. DBCode suggests a default filename with timestamp.
-
Wait for completion A progress notification shows the backup status. You’ll receive confirmation when complete.
Restoring a Backup
-
Navigate to your database In the DB Explorer pane, locate the target database.
-
Open the restore menu Right-click on the database name and select Restore Database….
-
Select restore options Choose any database specific restore options (if applicable).
-
Select backup file Choose the backup file to restore. File filters show compatible formats.
-
Confirm the operation Review the warning dialog and click Restore to proceed.
-
Wait for completion A progress notification shows the restore status. The database refreshes automatically when complete.
Best Practices
Before Backing Up
- Test your backup strategy: Verify backups can be restored successfully
- Consider disk space: Ensure adequate space for backup files
- Use appropriate formats: Choose formats based on your needs:
- Binary formats for speed and completeness
- SQL formats for portability and inspection
Before Restoring
- Create a backup first: Always backup the current state before restoring
- Verify the backup file: Ensure the backup file is from a compatible database version
- Check for conflicts: Be aware of existing data that may conflict with restored data
- Use test databases: Test restores on non-production databases first
Backup Naming
DBCode automatically generates backup filenames with this format:
{database_name}_backup_{timestamp}
Example: mydb_backup_2025-10-05T14-30-45.dump
This naming convention helps you:
- Identify the source database
- Track when the backup was created
- Organize multiple backup versions
Security Considerations
Backup Files
- Protect sensitive data: Backup files contain all database data, including sensitive information
- Store securely: Keep backup files in secure locations with appropriate access controls
- Encrypt if needed: Consider encrypting backup files containing sensitive data
- Clean up old backups: Regularly remove outdated backups to minimize exposure
Credentials
- DBCode uses secure methods (such as environment variables) to pass credentials to backup tools
- Credentials are not stored in backup files
- Connection credentials are required when restoring
Troubleshooting
Common Issues
Issue | Solution |
---|---|
”Backup failed: command not found” | Database client tools may not be installed. DBCode will provide installation instructions. |
”Permission denied” | Ensure you have write permissions for the backup location |
”Insufficient disk space” | Free up disk space or choose a different backup location |
”Restore failed: version mismatch” | Backup may be from a different database version. Check compatibility. |
”Database busy during restore” | Close connections to the database before restoring |
Error Messages
- “Missing [tool name]”: Required database client tools need to be installed. DBCode will provide specific installation instructions.
- “Cannot read backup file”: File may be corrupted or incompatible with the target database
- “Target database not empty”: Choose restore options to drop existing objects, or manually clear the database first
Technical Details
How It Works
DBCode uses the native backup and restore tools provided by each database engine to perform these operations. This ensures:
- Compatibility: Backups use standard formats recognized by each database system
- Reliability: Native tools are tested and maintained by database vendors
- Feature support: Full access to database-specific backup options and formats
Database tools are typically:
- Installed automatically by DBCode when possible
- Available from system package managers
- Bundled with the database installation
DBCode manages the complexity of invoking these tools with the correct parameters, providing a consistent and user-friendly interface regardless of which database engine you’re using.
The Backup & Restore feature provides a reliable way to protect your database data and migrate databases between environments, all within VS Code.