How far are you going?
Keep the sand damp, and the rocks wet and if it doesn’t freeze or get too hot the bacteria will be fine, for a day or two without much difficulty.
I would recommend rinsing the sand until it runs clear before putting it back in the tank. Dirty sand can release nasties that are dangerous to your coral and fish.
I would also rinse the rocks to remove loose dirt before moving and again right before you put them into the new tank.
If you have them in buckets for many days I would rinse them really well before traveling and again after.