You can do it with a diode and a capacitor, but then you will loose voltage over the diode. Using a schottky diode will reduce this drop to about 1/2 of a normal diode. If your application is sensitive to this drop, you can use a small transistor to do the switching. This will have an even lower drop.