So I've noticed I've been explaining to people how to properly backup their data, whether they are going to restore from backup or set device up as new after a restore/upgrade. It's getting tedious to cover all bases all the time, so I'm going to put a write-up here to link all the noobies to.

I'm sure all you experts out there don't need this, but for all you noobies who are a little paranoid about losing your stuff, here are a few things you should do to back up your device.

In iTunes:
1) Right-click your device, select "transfer purchases"
2) This moves all your iDevice apps that were not downloaded via iTunes into your iTunes library so you can sync them back in after your upgrade/restore.
3) Go to the "Info" tab in iTunes, select a third party you want to store your Contacts in. This is a safeguard in case a backup doesn't load up or if you're planning to set up as new.
4) Click sync.
5) Right-click device again, select "create backup" and let it do so. If you are planning to set up as new, this isn't of benefit to you.

In Cydia:
1) Aptbackup (not appbackup) will back up your list of installed packages. This does not always work so be careful. Write down all your packages and reinstall them manually after restore/upgrade if it doesn't work right. XBackup will also back up items in Cydia.
2) How it works: You install the app, you have it back everything up, then you do your restore/upgrade. When you rejb, you'll reinstall aptbackup and have it restore what it backed up.
3) This will require your to restore from a backup so if you don't use the backup created in iTunes immediately after using aptbackup, it won't work. If you're planning to set up as new, this isn't an option for you.
4) Compatibility on iOS 5 is questionable. This I'm not sure of.

In Cydia (other option):
1) Pkgbackup (paid app) will back up your list of installed packages as a contact. I've had flukes with this one as well, though I've heard good things about it from others as well.
2) How it works: If you don't back up your contacts, you won't be able to restore your packages. So be sure to do so if you're setting up as new. If you're restoring from a backup, your contacts will automatically be restored so it won't be a concern (unless your backup fails to load for some reason). So basically you install pkgbackup in Cydia before you create a backup in iTunes. In pkgbackup, let it back up your stuff. After your restore/upgrade, and after you sync your contacts (or if you load a backup onto your phone), reinstall pkgbackup and let it restore your packages.
3) Compatibility on iOS 5 is questionable. This I'm not sure of.

Via SSH:
If you want to be super safe, you can back up your device via SSH by extracting your files from your phone and moving them to your computer. You can then later move the files back into your newly restored/upgraded device. There is some complexity regarding text messages and game save data, which I really don't have any expertise in so watch out for that. The easy stuff like themes and ringtones and photos I can include. Subcategories as follows:

Photos/videos for Windows:
1) Just open My Computer, go to your device, and you'll be able to find the photos/videos there for you to transfer to your computer. If you're setting up as new, you should do this to keep your photos/videos. Without restoring from backup, those photos/videos are gone. They don't sync into iTunes.

Photos/videos for Mac:
1) One word: iPhoto.
2) iPhoto is pretty self explanatory, it just takes your photos from your iDevice and moves them all into it.
3) You could also SSH in and move them to a folder you'd prefer.

Thanks, but your wrong... Just restored from an earlier back up & everything I need is back, w/ my jaibreak in tact.

Really, this is only the second time in over 4 years of jailbreaking that I have heard of this (and still having a hard time wrapping my brain around it). All Cydia apps/tweaks etc. came back too? Well, good for you

To properly answer the original question, restoring from a backup does not wipe out any data. You won't lose a jailbreak over it. It's not an actual restore of the entire firmware, it's pulling a backup file and loading it onto the iDevice.

You can safely use the "restore from backup" option in iTunes via right-clicking your device. It is different from the "restore" in the summary page.