So I was wondering how you guys make an undo function.

Currently I have an undo function that works. When I move/rotate etc an object/mesh/light etc. I save the movement data. as I press undo, it just moves the object back where it came from. However I don't have an undo function when for example a texture changes.
It could easily be made, but I was wondering if you knew a better way if there is any.