Schema-aware Salesforce Data Export & Import Tool
SFData is a modern CLI tool that makes Salesforce data migration simple by automatically preserving relationships between records across different orgs.
The Problem: Migrating Salesforce data between orgs (Dev β QA β Production) is painful. Record IDs change, relationships break, and you end up with duplicate or orphaned data.
The Solution: SFData
Commands Available:
sfdata export- Export objects with virtual IDssfdata import- Import with relationship preservationsfdata cache- Manage schema cachesfdata orgs- List authenticated SFDX orgs
- Depth-based Relationship Traversal - Auto-export related objects (
--depth 2) - Interactive Mode - Choose which objects to include
- Add your own custom Python Plugin - Build plugins in Python
- Comprehensive Documentation - Full user guides and API docs
- Automated Backups - Scheduled backup capabilities
# Install from PyPI (alpha release)
pip install sfdatamigrate
# Verify installation
sfdata --versionIf you get "command not found" error:
The sfdata command may not be in your PATH. Choose one option:
Option A: Add to PATH (One-time setup)
Windows:
- Press
Win + Xβ System β Advanced system settings β Environment Variables - Under "User variables", select
Pathβ Edit - Add:
C:\Users\YourUsername\AppData\Roaming\Python\Python312\Scripts - Click OK and restart your terminal
Or via PowerShell (Admin):
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$env:APPDATA\Python\Python312\Scripts", "User")Mac/Linux:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcOption B: Use python -m (No setup needed)
python -m sfdata version
python -m sfdata export Account --org myorg# Authenticate with Salesforce CLI
sf org login web --alias myorg
# List authenticated orgs
sfdata orgs
# Use directly - no token copying needed!
sfdata export Account --org myorgIn Your Target Salesforce Org:
- Go to Setup β Object Manager β Account β Fields & Relationships
- Click New
- Select Text β Next
- Configure:
- Field Label:
SFDATA External ID - Field Name:
SFDATA_External_ID - Length:
255 - β External ID
- β Unique
- Field Label:
- Click Save
Repeat for other objects you plan to import (Contact, Opportunity, etc.)
π‘ Future versions will auto-create this field for you
# Export from your authenticated org
sfdata export Account --org production --limit 100 --output accounts.json# Import to your target org
sfdata import accounts.json --org uat-sandbox --verboseResult: Records created in target org with all data !
Check your target org:
- Records imported successfully
SFDATA_External_ID__cfield populated with virtual IDs
Re-run import: It will update existing records (no duplicates!)
# Export using SFDX org alias
sfdata export Account --org myorg --output accounts.json
# Export multiple objects
sfdata export Account Contact Opportunity --org myorg --output data.json
# Export with WHERE clause
sfdata export Account --org myorg --where "CreatedDate = LAST_N_DAYS:30" --output recent.json
# Export with limit
sfdata export Account --org myorg --limit 5000 --output test.json
# Verbose mode (see detailed logs)
sfdata export Account --org myorg --verbose --output accounts.json# Import using SFDX org
sfdata import data.json --org target-sandbox
# Dry run (validate without importing)
sfdata import data.json --org myorg --dry-run
# Import with verbose logging
sfdata import data.json --org myorg --verbose
# Different import strategies
sfdata import data.json --org myorg --strategy insert # Insert only (fail if exists)
sfdata import data.json --org myorg --strategy update # Update only (fail if not exists)
sfdata import data.json --org myorg --strategy upsert # Upsert (default for virtual IDs)# List available authenticated orgs
sfdata orgs
# Export from one org
sfdata export Account --org production --output prod.json
# Import to another org
sfdata import prod.json --org uat-sandbox
# No need to copy tokens or URLs!# View cache statistics
sfdata cache stats
# Clear cache for current org
sfdata cache clear-
Manual Field Setup Required
- Must create
SFDATA_External_ID__cfield manually on each object - No auto-field-creation yet
- Must create
-
No Depth Traversal
- Must specify all objects explicitly
- No automatic child relationship discovery yet
- Coming in beta release
-
Limited Error Handling
- Some edge cases may not have helpful error messages
- Improving based on user feedback
-
Owner Assignment
- Assigns records to running user or first admin found
- No smart owner mapping yet
-
Documentation
- User guides are minimal
- Comprehensive docs coming soon
- Test in sandbox first - Always!
- Backup your data - Before any import
- Start small - Test with 10-100 records first
- Use --dry-run - Validate before importing
| Feature | Data Loader | SFData |
|---|---|---|
| Relationship Preservation | β Manual CSV mapping | β Automatic |
| Cross-Org Migration | β Guided virtual ID system | |
| RecordType Mapping | β Manual | β Automatic by DeveloperName |
| Idempotent Imports | β Creates duplicates | β Safe re-imports |
| CLI/Automation | β CLI-first |
| Feature | SFDMU | SFData |
|---|---|---|
| Configuration | Complex JSON required | Auto-detect from schema |
| Learning Curve | High | Lower (auto-discovery) |
| Relationship Handling | Manual mapping | Automatic virtual IDs |
| Development Stage | Mature | Alpha (experimental) |
SFData's Niche: Easier cross-org migration with less configuration.
SFData uses Salesforce CLI (SFDX) for authentication. Authenticate your orgs using:
# Authenticate to an org
sf org login web --alias myorg
# List authenticated orgs
sfdata orgs
# Use with any command
sfdata export Account --org myorgCreate ~/.sfdata/config.yaml:
cache:
enabled: true
ttl_hours: 24
logging:
level: INFOSolution: Create the field manually in your target org (see Quick Start Step 2)
Solution: This is a warning. Records will be assigned to default owner. No action needed.
Solution: A record with this external ID already exists. The pre-sync feature will handle this automatically.
Solution: This is correct! Virtual IDs allow idempotent imports. Re-running updates existing records.
Proprietary License - All Rights Reserved
This software is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software, via any medium, is strictly prohibited.
For licensing inquiries: mayank.shete@gmail.com
- Documentation: See examples above
- Support: mayank.shete@gmail.com
- License Inquiries: mayank.shete@gmail.com
# List SFDX orgs
sfdata orgs
# Export with SFDX
sfdata export Account --org myorg --output accounts.json
# Import with SFDX
sfdata import accounts.json --org target-sandbox
# Check what would be imported (dry-run)
sfdata import accounts.json --org myorg --dry-run
# View cache stats
sfdata cache stats
# Get help
sfdata --help
sfdata export --helpQuestions or Support? Contact me at mayank.shete@gmail.com