As you toil away on your computers and other devices day after day, how many gigabytes of data are you churning out each year in the form of photos, financial records, creative endeavors and other priceless digital files? More importantly, what if the computer or external drive where all those files are stored suddenly dies?

Unfortunately, mechanical drives last only about five to 10 years with normal wear and tear. Flash drives and newer solid-state drives have no moving parts, but their chips live only so long. Drives and devices also get dropped and run over. People mistakenly delete files and accidentally re-format their drive. Viruses and failed upgrades and installs corrupt data.

So what do you do when your data suddenly goes poof?

Don’t panic. Lost data can probably be recovered, though it can cost hundreds to thousands of dollars. Here’s what to do if disaster strikes — and how to avoid it in the first place.

First, do no further harm

If you hear strange grinding, clicking or other noises coming from a mechanical drive, immediately turn it off. This could indicate drive failure or physical damage caused by a torn or dead head, scratched platter or stuck spindle motor.

Don’t try to get it running again, because that could cause more damage and data loss. Fixing this involves complex electronic surgery and will cost the biggest bucks.

Get professional help

Start at a good computer-repair shop. Through April 25, Checkbook is offering Washington Post readers free access to its ratings of local shops: ­checkbook.org/washingtonpost/­computer-repair.

Most shops can handle simple data recovery but typically lack the training, equipment and facilities to operate on a physically damaged drive. If they can’t solve your problem, they’ll probably refer you to a specialist.

Find local specialists

Get referrals to local specialists, if possible. That way, you can talk face to face with the person who will do the work. “There’s no industry standard certification for data recovery, so you want to get a gut sense” of whether the specialist competent, says Steve Burgess, president of Burgess Forensics in San Luis Obispo, Calif.

You want someone well trained in this methodical precision work. Burgess, for example, started what he believes was one of the first U.S. data recovery services in the San Francisco Bay area in 1984 and has since done about 20,000 recoveries.

Ask the specialist to explain how they’ll get the data. Do they have a clean room (where filtered air minimizes dust particles and contamination of the drives when they’re opened up)? Get cost estimates.

National specialists

Several national services also do recovery, and Checkbook asked computer-repair pros which ones they recommend based on their own experiences. Their picks:

•DriveSavers Data Recovery

•Gillware

•Data Savers

•Lazarus Data Recovery

No physical damage? Try DIY

If the drive is not making cringeworthy noises, it probably isn’t damaged but may have a “logical error,” a sudden inability of the disc controller software to find and access some of the data on the disc. This is a simpler recovery problem that computer-repair shops can usually handle.

But believe it or not, experts say you may be able to recover the data yourself — if you’re comfortable with technology, want to avoid paying someone else and are willing to risk failure and maybe further data loss. Try these fixes (and run to a repair pro if they don’t work):

If your computer won’t start, the “boot” files are probably damaged, but the data files may be fine. Remove the computer’s internal drive, and buy a SATA interface case for $10 to $20. The internal drive plugs inside the SATA case, which turns the whole thing into an external drive with a USB cable.

Plug that cable into a different, functioning computer, which should be able to read the data files. Copy the data off the bad drive onto a new one. Avoid this major screw-up: “A lot of do-it-yourselfers try to save the data they’re recovering to the same drive that has a problem,” says Jon Yaeger, owner of Data Savers. That can overwrite the source files they’re trying to recover and eventually destroy a lot of data before it can be recovered.

“It’s like a snake eating its own tail,” says Brian Gill, chairman of Gillware. Once a drive writes over what’s already written on a sector, the original is gone. “We can’t recover that, and we see that once or twice a week,” Gill says.

Try recovery software

If that doesn’t work, you may have a file structure problem. Keep the SATA drive plugged into that second computer, and download recovery software. There are plenty of brands, including Stellar and GetDataBack.

These will scan your drive and tell you if files can be recovered. If they can, you pay $79 (GetDataBack) or $80 (Stellar) to buy the files. Then, copy the files to a fresh drive — and not to the same problematic drive. If this software can’t get your data, you pay nothing.

This same software can also recover accidentally deleted files and — if you’re a real newbie — accidentally re-formatted drives.

Shop for the best price

Prices range widely. Simple recoveries due to logical problems can cost $100 to $1,000. Recoveries from physically damaged drives can run $600 to $2,500.

You should get a ballpark price, but you won’t know the final cost until someone actually looks under the hood free or for a diagnosis fee of $30 to $70.

Generally, if the service can’t recover data, there’s no further charge. If it can, you’ll have to decide if those lost files are worth the recovery cost.

Back it up

To prevent all this from happening again, back up your digital stuff.

•Focus on your photo files, which are the ones consumers want to get back most. Because storage is cheap, keep multiple backups of your highly prized files on more than one high-capacity drive. One convenient way to do that is with the Western Digital My Book Duo, a case with two drives inside, which store mirror images of the data; if one fails, get your data from the second drive. Cost with four-terabyte capacity: about $230.

•Also back up to a cloud. Two drives in the same place could still be taken by hurricane, tornado, fire, flood or thieves. A cloud server is an easily accessible redundant off-site location. Consider free and paid services such as Google Photos (photo files capped at 16MP, videos 1080p), Dropbox, Apple, Amazon, MegaBackup, MediaFire and FlipDrive.

•If one or more older external hard drives have piled up around your house, offload their contents to new drives and write the purchase date on the new drive with permanent marker so you can plan for that drive’s ultimate demise several years from now.

•For the ultimate in archiving longevity, Mike Cobb, DriveSavers’ engineering director, recommends optical storage, specifically Millenniatta’s M-Disc DVD+R and BD-R discs, which are rated to last 1,000 years. An M-ready DVD burner and 30 4.7GB optical discs cost $108 and should cover you for the next 30 generations. “Of course, we won’t know for sure if this is true for another 995 years, give or take,” Cobb says.

Washington Consumers’ Checkbook (Checkbook.org) is a nonprofit organization with a mission to help consumers get the best service and lowest prices. It is supported by consumers and takes no money from the service providers it evaluates. You can access Checkbook’s ratings of computer repair shops, as well as its full article about data recovery at no cost until April 25 at checkbook.org/washingtonpost/computer-repair.

More from Lifestyle: