Add snapshot function and its conditional execution

Change-Id: Ib35b11d0ce26678a09b7b3c17360345c85ab763e