"Purana data saath lekar chalna hai. Kachra nahi."
"We must bring the old data along. Not the rubbish." A new system is only trusted if its data is.
- Which tool?
- Insert or upsert?
- What order?
- Why did 3,000 rows fail?
- How do we undo it?
Step 13: Data Migration
You will move existing data into Salesforce and out of it safely, using the Data Import Wizard and Data Loader: insert, update, upsert, delete, hard delete, export and export all, with planning, cleansing, external IDs, error handling, reconciliation and rollback.
You are hereSteps 1-4 Requirements and configurationSteps 5-9 DevelopmentSteps 10-11 Test and deploySteps 12-15 Rollout
Hook: go-live Monday, and nobody trusts the data
A dealership loaded its old customer Excel into Salesforce the weekend before go-live. On Monday morning:
- Priya Sharma appeared three times, once as "PRIYA SHARMA" and once as "Priya Sharma ".
- 4,000 customers were owned by the admin, because the old owner names didn't match any user.
- Every birthday was a month out, because 03/04/1990 was read as 4 March instead of 3 April.
- Nobody could undo it, because nobody had kept the IDs of what was loaded.
Consultants went back to Excel within a week. The data loading itself took one hour. The missing planning cost the whole project.
By the end of this workbook, you will be able to
- Plan a migration: scope, load order, tools, owners and rollback.
- Choose between the Data Import Wizard and Data Loader.
- Use insert, update, upsert, delete, hard delete, export and export all correctly.
- Use External IDs to match records and link parents to children.
- Prepare files that load first time, and fix the ones that don't.
- Reconcile counts and totals, and roll back safely.
Concept: the migration lifecycle
Load parents before children
A child record needs its parent to exist first, because it stores the parent's ID. So the order follows the data model you designed in Step 2.
Import Wizard and Data Loader
Data Import Wizard, step by step
- Go to Setup > Data Import Wizard and choose Launch Wizard.
- Choose the object, such as Accounts and Contacts, Leads, or a custom object.
- Choose what to do: Add new records, Update existing records, or Add new and update existing records.
- Choose how to match existing records, such as Salesforce ID, name, email, or an External ID.
- Decide whether workflow rules, processes and flows should run for these records.
- Upload the CSV file, and choose its character encoding.
- Map each column to a Salesforce field. Fix any unmapped columns.
- Start the import. Check progress in Setup > Bulk Data Load Jobs, and you'll get an email when it's done.
Data Loader, step by step
- Download Data Loader from Setup > Data Loader, or from Salesforce's developer site, and install it. It runs on Windows and macOS.
- Log in with OAuth, choosing Production for a Developer Edition or production org, or Sandbox for a sandbox.
- Choose the operation, and the object.
- Choose the CSV file, for loads, or write the SOQL query, for exports.
- Map the fields. Use Auto-Match Fields to Columns, check each one, and save the mapping as an .sdl file to reuse.
- Choose a folder for the success and error files, and finish.
- Open the error file: each failed row with the reason. Fix the rows and load only the error file again.
Data Loader settings that matter
Every operation explained
Try it: insert, update or upsert?
Salesforce already holds three customers. You load the file below. Choose an operation and see what happens to each row. The External ID field Legacy Customer ID is marked Unique.
Already in Salesforce
Your file
Preparing data that loads first time
Understand IDs
The preparation checklist
Common errors and their fixes
Reconcile and roll back
- Count: rows in the source file, minus rows you excluded, equals successes in Salesforce.
- Totals: sum of amounts, such as booking values, matches between source and a Salesforce report.
- Samples: open 20 random records and compare every field with the source.
- Rollback: keep every success file. Its first column holds the new Salesforce IDs, so a Delete with that file undoes an insert. Before any mass update, Export the records first, so that an Update with the export puts the old values back.
Demo: Kaveri Motors
Kaveri Motors is retiring its old dealer management system. Here is the migration plan for Org C.
Practice files
These small files mimic the real ones, including the kinds of mistakes real data has. Download them for Exercise 1.
Build it in Org C
- Fields: on Account, create a text field Legacy Customer ID, ticked as External ID and Unique. On Asset, create VIN the same way.
- Bypass: assign the Data Migration Bypass permission set from Step 3 to your migration user, so that rules don't block historical data. Add the same custom permission to your flows' entry conditions in Step 14.
- Find IDs: with Data Loader, Export the RecordType object with
SELECT Id, Name, SobjectType FROM RecordTypeto get the Person Account record type ID. Export Users the same way, to map owner names to user IDs. - Customers: open customers_legacy.csv. Fix the dates to YYYY-MM-DD, add RecordTypeId and OwnerId columns, then Upsert into Account on Legacy Customer ID.
- Read the error file. Fix the rows and upsert only those again.
- Vehicles: Upsert vehicles_legacy.csv into Asset on VIN. On the related objects step, match Account by Legacy Customer ID instead of the Salesforce ID.
- Seminar leads: import leads_seminar.csv with the Import Wizard, adding them to the Corporate Fleet Seminar campaign.
- Reconcile: compare counts and check five records by hand. Record the results in your Migration Pack.
- Remove the bypass permission set from the migration user.
Practice: Suraksha General Insurance
Suraksha has much more data, and much more sensitive data. Choose the right tool and operation for each job.
Which tool and operation?
Suraksha's volumes
Three exercises
Exercise 1: Load, fail, fix, reload
- Download the three Kaveri practice files.
- Load them as in the Demo. Expect some rows to fail.
- For each failed row, write the error, its cause and your fix in the Migration Pack.
- Reload only the fixed rows. Reconcile: source rows, successes, rows deliberately excluded.
Exercise 2: Export, mass update and roll back
- Export all open leads:
SELECT Id, Status, OwnerId FROM Lead WHERE IsConverted = false. Keep this file safe as your backup. - Copy it, and change the Owner of every lead from one consultant to their manager, as if the consultant left.
- Update with the changed file. Check in Salesforce.
- Now undo it: Update using your backup file. Check the owners are back.
- Delete one test lead, then use Export All with
WHERE IsDeleted = trueto find it. Restore it from the Recycle Bin.
Exercise 3: Plan Suraksha's load order
Give each object a load position from 1 to 10. Anything that depends on another must load after it.
Build your Migration Pack
This is the document a client signs before go-live. Your work saves in this browser on this device.
Build with AI
AI is excellent at writing SOQL, mapping columns and spotting messy data patterns. It must never see the real data.
Reflect and exit check
Quick test
Exit check: are you ready for Step 14?
Interview preparation
Practise saying these answers aloud, then use our AI interview agents for feedback.
For your resume and portfolio
Trainer notes
Open the suggested session plan and coaching notes
| Session | Cover | Students leave with |
|---|---|---|
| 1 (90 min) | Hook, lifecycle, tools, operations. Upsert simulator until everyone can predict it. Install Data Loader. | Data Loader installed and logged in |
| 2 (90 min) | Preparation, IDs, errors. Exercise 1 live: load, fail, fix. | Kaveri data loaded and reconciled |
| 3 (90 min) | Exercise 2 export and rollback; Suraksha drill; Exercise 3 load order. | Migration Pack, reflection and exit check |
Common mistakes to catch
- Dates in DD/MM/YYYY without changing the Data Loader date setting. Use YYYY-MM-DD.
- Saving CSVs in Excel, which can change leading zeros, long numbers and encoding. Check in a text editor.
- Using Insert for a second run, creating duplicates. Use Upsert with an External ID.
- Forgetting to remove the bypass permission after the load.
- Running hard delete outside a sandbox. Make students explain it before they're allowed to.
Check before each batch
Download the current Data Loader version and confirm its install steps, login options and the list of operations in its menu. The command-line interface is Windows-only, so plan the demo accordingly.