There are two competing bond fund risks. One is interest rate risk: the risk that if interest rates go way up, your existing bonds will decline in value until their coupon payments equal the new higher rate bonds relative to their price, which makes you sell at a loss if you need the money sooner. The other is reinvestment risk: the risk that if interest rates go way down, when your existing bonds will mature and you will be forced to reinvest at a very low rate, whereas a long term bond would keep paying the same high rate. Either one can cause you to have less money than you should have.
If interest rates go way up, the coupon payments and maturing bonds from existing bonds will be reinvested at higher rates, and will eventually make up and then far more than make up the difference to the lost principal. The time it would take to break even is expressed by a bond fund's duration, but the duration is only an indication and not the exact result you will get because the exact result is path dependent on the actual series of sizes and timings of interest rate changes.
The basic rule of thumb is to invest in bond funds with a duration similar to the length of time you expect to keep your money in the bond fund, because that is where you minimize the combined effects of reinvestment risk and interest rate risk.
For example, I plan to keep my bond funds for a very long time so I invest in very long term bonds, but as I approach my "enough" $ amount I invest more in shorter term bonds because I need that money sooner. Another popular approach is to say "I don't know when I will need the money, and I don't want to try and outguess the market on future rates, so I will use bond funds matching the market duration." Money market funds are ideal for money needed in the next year, but farther out than that consider longer duration funds. For example, if I sell my house and plan to buy another soon, I will use a money market fund because I only plan to use that fund a short while and don't worry about a need to reinvest at a high future rate to sustain long term returns.