Ransomware is a hacker's cash grab. When this type of malware attacks your PC, it locks your precious files behind a password and demands payment for unlocking your docs. As in any other hostage situation, paying the ransom may or may not get you your files back. With ransomware, an ounce of prevention -- backing up all your important files -- is worth a pound of Bitcoin cures. Here's how to foil ransomware.

Store important files on an external drive

Internet hackers might be able to infiltrate your computer, but they can't get to an external device (like a thumb drive or a standalone hard drive) if it isn't connected to your PC or a network. So besides all the other reasons you should back up your data, doing so is an important fail-safe in case of malware assault.

And saving your files to an external disk is both cheap and easy. You can buy a 1TB external hard drive for about $60, and it simply plugs into a USB port on your computer. This type of drive has preinstalled software that will walk you through backup and setting a password on the drive (which we recommend). Note: If you get a mechanical drive, you'll want to keep it stationary when it's in operation (and for a few seconds afterward), because it has moving parts. If you pick it up while it's in motion, there could be internal damage.

western digital 1TB external hard drive

Alternatively, if you don't need as much space (and you usually don't if you're primarily backing up text documents and spreadsheets), you can get a solid-state external drive. These use flash memory, so you can move them around when they're transferring data, and they don't make any noise. About $100 will get you a 250GB drive from Sandisk or Samsung. That's one-fourth the space of that 1TB drive we mentioned, but that's the price you pay when upgrading from mechanical storage. External SSDs can also take particular advantage of the speed of a USB 3.0 port.

USB 3.0 and 3.1 (collectively referred to as 3.x) usually have a blue connector. USB 3.x is much faster than the older, more common USB 2.0 ports. However, if you're backing up less than 1GB at a time, even USB 2.0 should be fast enough. If your desktop doesn't have USB 3.x ports, it may have an internal slot where you can install a card with USB 3.x ports on it.

anker USB 3.0 hub

Use cloud storage as an additional backup

While we highly recommend external drives for data backup, they're not the end of the story. You should save your important files to the cloud. This way, if your computer and your external drive get lost, stolen, or damaged, you still have a Plan C for your data. Some cloud services even let you back up files incrementally, like every 30 seconds. It's almost like using Google Docs or Google Sheets.

We took a census of your options last year, and SOS Online Backup came out on top. Unlike Google Drive, iCloud, or Microsoft OneDrive, SOS has an option that doesn't keep a copy of your encryption keys. That means you and only you know the password to your online vault. This high degree of privacy is important for sensitive documents like tax records and stock portfolios.

Also, SOS can keep effectively unlimited versions of your files. So if you need to go back and restore old data in a document or spreadsheet, it's all there in the cloud. Unfortunately, SOS does incremental backup for individual files instead of entire folders, so there's a little more setup involved. SOS lets you back up as many as five PCs and unlimited mobile devices, for $5 per month.

Carbonite (Windows, Mac) and SpiderOak One (Windows, Mac) are other good cloud storage options, though they cost more and may limit how many devices you can back up.

If you must pay ransomware, use a gift card

If you don't have backed-up files, you may have little choice but to to pay the ransom to get your files unlocked. In that scenario, don't use your debit or credit card. Your card info can be used to make unauthorized purchases in your name -- possibly of illegal items -- and it may be leveraged to get other personal information.

Instead, try a gift card with the MasterCard or Visa logo on it. This may not work -- the ransomware may use a transaction processor located outside the United States, where such gift cards ordinarily don't work. In that case, you need an international gift card like Visa TravelMoney. Check Visa's webpage to search for nearby stores that sell them.

If you must use your regular debit or credit card, cancel it right after paying the ransom to prevent unauthorized purchases.

Tom is the senior editor covering Windows at Download.com.