It's OK, Your Data Isn't Gone Forever

Backing Up Your Org

Have you ever wondered what to do if something goes wrong and you lose your Salesforce data?  Well, good news for you, you aren’t totally screwed, bad news, it isn’t cheap and you can’t get all of it back. Now, before going through the details on how to recover your data, let’s first review how we can prevent this situation from happening again. Even if this is a crazy-random-happenstance that you don’t think will happen to you, reading best practices is a good refresher for everyone.

Please note this is a small list of options for backup and recovery. There are far more available on the AppExchange, GitHub, etc.

  1. Prevent  

  2. Prepare  

  3. Handle   

Prevent

Data recovery doesn’t need to be a big giant freak-out thing.  Seriously.  You need to create a change management, rollback, and backup plans so that you will be prepared, G-d forbid anything happens.

Security

With great power comes great responsibility.

-Amazing Fantasy #15,

Although the quote is often credited to Uncle Ben (Peter Parker’s Uncle), it actually first appears in a caption, either way, true fact.

You can adjust user permissions for minimal damage, so do so. Contrary to every admins dream world, users are not sitting around learning about Salesforce in their free time; they don’t stay up late studying best practices.  Therefore, with the wrong permissions, they could cause your world to flip upside down.

  1. Don’t give out the “Modify All” permission to end users. This is for admin only.
  2. Do not give “delete” to end users, if they want a record deleted, they can ask an admin or Power User.
  3. Do not allow them to make changes in Setup that is your admin only zone
  4. Don’t give them more super powers than they need.

Change Management

Having a solid change management plan and proper governance will increase adoption and simplify your life. How to do all of this we can cover at another time, for the time being we will keep it simple.

Use Your Freakin’ Sandbox

Outside of reports & dashboards, there is no reason to make changes in production; it is risky and bad for business.

  • Creating a validation rule can kill your code coverage.
  • Changing a field type can wipe out all your data
  • A small typo in a Workflow rule can change all your customers to inactive

Make all changes in the sandbox and test them in the sandbox.  What do I mean?  Don’t just see if the WFR works go and update existing records, then run some reports, see what happens to your data, not just, if you can save the rule.

Don’t forget you can test imports in your sandbox too, if you have a large change, see how the data is affected in your SB before modifying production

Follow a Process

  • By creating and following a standard process for admin changes, you will have increased visibility into Salesforce, higher adoption, “in the know” users, less roadblocks, creating a better org all around.
  • You are less likely to have bugs because you have checks and testing in place.
  • Continuously test, don’t wait until the end

Train Your End Users

  • Educated users are less likely to have an uh-oh moment
  • Educated end users know what the shiny red button does

Prepare

On the Fly Backup

Pull a copy of your data before mass updating it.  You don’t really need to do anything, just copy the file before you modify it to upload.  Then, if you need to undo, you can just upload the unedited copy of your file.

Before doing a mass update, update just 5-10 records to see what happens, make sure your fields are mapped right, that the right workflows fire, and there is a EotW situation.

If you need to change a field type, export all the data in that field + record Id before making the change.  Add this backup to your archive.  More about Field Breakups here.

Data Export

Use the Data Export service.  Salesforce offers a FREE data export service, once every 6 days (the weekly export) for Enterprise, Performance, and Unlimited orgs, or every 28 days (the monthly export), for all other editions except database.com.  This service is free; it could save you a headache, time, and money.  If you haven’t already set it up NOW.  Now this service is only useful if you actually download the export when it is ready.

Metadata Backup

Now, don’t be scared or intimidated, this is nothing to fear. In addition to making backup copies of your data, you need to backup your metadata. Metadata is everything in Salesforce that is not a record, such as reports, fields, validation rules, workflow rules, list views, etc. The best way to do this is to make sure to make a copy of your system configuration before each deployment. Again, this is a great rollback tool and it can save your a$$ down the line.

The best way to do this is with the Force.com IDE, MavensMate, or Haoide. The Force.com IDE is an “add-in” that you install inside Eclipse. MavensMate and Haoide are “add-ins” you install in Sublime. I prefer the Haoide. I find it the easiest to use and the fastest. Because of that fact, I am going to go through instructions on how to make a backup using the Haoide.

Once Installed

  1. Once installed, create a project for your org.
  2. In the menu go to Haoide – Metadata – Toggle Metadata Objects
  3. Select the all checkbox and click outside of the window
  4. Click Yes
  5. You now have a copy of all your metadata. Throw it in a folder and zip that baby. It’s that easy. Just remember to save the files somewhere safe, like with your weekly/monthly Data Exports.

That’s it, easy-peasy! Wasn’t as scary as you thought was it?

Handle

No matter how much we backup and prepare, life happens and people make mistakes, but that’s totally ok.  There is no need to panic, there are no snakes on this plane.  First things first, what happened?

Restore Metadata

Within 15 Days

If you are like most admin, you probably skimmed or skipped reading the popup when you deleted your custom field, but that is ok. Although deleting a field will delete all the data and dependent information, you have 15 days after hitting the delete button before that happens.

Go to the object that you deleted the field off of and pullup the “Fields” screen in setup. At the bottom of your field list, there should be a link that says “Deleted Fields”, click it.

Setup - Customize - Lead - Fields - Deleted Fields

Now you can view all the fields deleted within the last 15 days that have not been erased. To erase the field and the data within the field forever and ever press “Erase” (not 100% true) to restore, press “Undelete”

FYI
  • At the end of the field’s developer name, you will see “_del” has been added. When you click undelete, you will need to edit your field and manually update the Developer Name to remove the “_del”
  • When you undelete the field, the data in the field and the field history are restored. In addition, if it is a lead field mapped for conversion, the mapping is restored also.
  • Be patient, if you see “#Error!” or blank values that shouldn’t be, don’t panic, it takes time for the data to be restored
  • Field history data for the deleted custom field is restored.

After 15 Days (Or Other Metadata)

Fields and other metadata can be restored a handful of ways. I am going to start with the easiest.

  1. If you have a sandbox that still has the field, you need to restore, bring it over in a change set.
  2. If you have a backup of your metadata (described in the metadata section), you can deploy the field/List View/Workflow rule from the data you have. In-depth instructions in another post, for the time being, you can follow the directions, or ask one of those fabulous & wonderful developers or engineers to walk you through. They are just the bee’s knees aren’t they?

Undo an Update

Now, what about when you didn’t delete a record, but you updated it and a workflow rule fired that updated all the customer addresses to say 123 Main St. Now none of your accounts have the right address, your territories are out of whack, and this other rule to update the owner has reassigned everything. Shiz, Super, Eff-bomb.

Don’t scream yet. Remember that rollback file you made? The pre-update copy of your data? Yeah, that’s the one. Grab the untouched CSV and update the records. It is that easy. You might want to turn off the WFRs when you update to prevent things from going crazy again.

Now if you have inserted records incorrectly, you can undo your import with a delete.

Recover Deleted Data

If it has been 15 days or less, you can still access your deleted data via the recycling bin.

Recycling BinRecyclingBin

Ronald McDonald taught us to reduce reuse and recycle, and if you deleted a record (data) and not metadata, follow Ronald’s advice and hit the recycling bin. You recycling bin holds records for 15 days before permanently deleting them, so if you just deleted a record (or set of records) and need to restore them, the recycling bin is the place to go.

To access the recycling bin you need to be in Salesforce Classic, sorry Lightning Admin, but you need to switch for a minute to access. Now, navigate to your super-fab sidebar on the right, and at the bottom you should see “Recycling Bin” & click it. Here you have a lovely list or records that have been deleted

My Recycling Bin
To undelete your records, just select the checkbox in front of the name and click “Undelete”

FYI
  • Undeleting a record will not only restore the record, but reestablishes the record’s relationships such as parent accounts, parent cases, more relationships here.
  • Your Recycle Bin record limit is 25 times the Megabytes (MBs) in your storage. Meaning:
    • If your organization has 1 GB of storage,
    • Then your limit is 25 times 1000 MB, or 25,000 records.
  • If you reach the Recycle Bin limit, the oldest records are auto-removed, so long as they have been in the bin for at least 2 hours
  • The recycling bin is only accessible in  Salesforce Classic, click here to vote for the idea to add the recycling bin to Lightning
  • More information available here

Query for Deleted

Now you might be thinking, “the Recycling Bin is all fine, and dandy, but I don’t want to manually select the 1500 records I need to restore.” No worries, there is a solution for you too. You can actually query with a SOQL query for deleted records. First, open your tool of choice for exporting, the DataLoader, Salesforce Inspector extension, and Workbench are all great options.

DataLoader Instructions
  1. Open the DataLoader and Login
  2. Select “Export All” (not export but export all).
  3. Select the object you want to export the data from
  4. Select the fields you need to restore (If you know which records and don’t need to manually review the data in the fields, just select Name, Id, LastModifiedBy.Name, and IsDeleted
  5. Add the filter criteria of IsDeleted = True and any other details to help you narrow down your data.
Salesforce Inspector
  • Click the extension on the right of your screen and click “Export Data”
  • Check the checkbox to include deleted & archived records
  • Enter your query, including IsDeleted = True
    • E.g. SELECT Name, Id, LastModifiedById FROM Opportunity WHERE IsDeleted = True and LastModifiedById = ‘00537000000Hz1G’ and LastModifiedDate >= YESTERDAY)

Now you have the Ids of the records you need to restore, update the IsDeleted column from TRUE to False and update. Bam! You’re-good-to-go.

Data Export File

That fabulous data export you have been doing monthly/weekly, well here where it saves your life. If you have something catastrophic happen E.g. you did a hard delete, or you deleted a field over 15 days ago, or worse, do not freak, it is ok. You have your data export files. Find the object that you need to restore the records for and insert/update without export. Not too bad, but keep in mind, the data is only as fresh as your last export, so don’t just schedule your export, download your export.

Data Recovery Service

When you lose it, and there is no other choice, there is still hope.  Salesforce has a service to recover your data. Data Recovery Services can help you restore structured data (like Account records), but not metadata, which includes List Views, Reports, Workflows. You contact your AE then Salesforce goes and recovers your data and gives it to you in a CSV file. Then you need to import the data.

Data Recovery Services Review
  • What you get: Data records
  • What you don’t get: List views, Custom fields, workflow rules, other metadata, you get the data, not the configuration
  • How long: 20 business days
  • Cost: $10,000 USD
  • How far back: 90 days back from today’s date.  Records deleted more than 90 days ago are not available.

Again, you must import the data; Salesforce cannot import the file(s) for you. If you deleted a custom object, you will have your records but you will need to recreate the fields, workflows, validation rules, etc. from what you have now. Hopefully, that would be a lovely metadata backup from the IDE

Advertisements

3 thoughts on “Backing Up Your Org

What are your thoughts? Seriously, comment.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s