Backpacks can trap all kinds of odors inside because they are often made from fabrics that don't breathe well, such a nylon and polyester. A backpack can pick up odors from its surroundings, its contents, spilled liquids and even the wearer's perspiration. It might take some time and a little elbow grease, but you should be able to get that backpack smelling fresh again.
Read the backpack manufacturer's care instructions carefully to find out if it is machine washable and if you are able to submerse it in water. If you no longer have the instructions, contact the manufacturer.
Take everything out of your backpack, and open all pockets and compartments all the way. Turn the backpack inside out. Vacuum it thoroughly with a cornering attachment, especially in corners and along seams.
Let your backpack air outside in a breeze, or in a cool place, for at least a day.
Hand wash your backpack if the odor lingers. Use a damp sponge or cloth and a little mild laundry detergent. Use a scrub brush to really scrub all surfaces, inside and out, with the soapy water. Rinse the backpack thoroughly with clear, cold water and let it dry.
Soak your backpack If it still had a bad odor and if the manufacturer permits soaking. Let the backpack soak overnight in a tub filled with water, 1/2 cup of baking soda and a few drops of lavender essential oil (if desired).
Wash the backpack in the washing machine as a last resort, but only if the manufacturer permits machine washing. Wash the backpack alone using the gentle cycle. Remove any loose or detachable strings or ties before washing. Add 1/2 cup of white vinegar to the machine right before the final rinse cycle begins.
Let your backpack air-dry for at least a day.