Detect when object is sliding backwards
getLinearVelocity() provides you the motion vector you object was travelling since the last frame to reach the position it is now.

The motion vector is the vector from the last position (L) to the current position (C).

With the scalar or dot product you can determine if the previous position was in-front or behind the current position. You can even determine if it was left/right or over/under the object.

Before you can calculate anything you need to define what is front and what is behind. You need an Front/Behind orientation vector. Lets assume the border is the local XZ-plane. 


anything that is at the positive Y-axis is front
anything along the negative Y-axis is back. 
anything on the XZ-plane is neither back nor front (it is left/right/over/under)


For correct calculation all vectors needs to be in the same space. I suggest to use the scene space (world) You convert the orientation vector to scene space (relative to the objects origin):

from mathutils import Vector

FORWARD_ORIENTATION = Vector([0, 1, 0])
forwardOrientationVector = object.worldOrientation * FORWARD_ORIENTATION 


The dot product projects one vector on the other and tells how much of the vector the projection uses. The calculation is pretty simple, but we still use the dot operation mathutils.Vector provides:

forwardRatio = forwardOrientationVector.dot(object.getLinearVelocity())


You check the range of the result, to get one of the three possible values:

if forwardRatio &gt; 0.0:
    print("forward")
elif forwardRatio &lt; 0.0:
    print("backward")
else:
    print("neither forward nor backward")


Similar calculations can be used to determine left/right (RIGHT_ORIENTATION = Vector([1,0,0])) and over/under (OVER_ORIENTATION = Vector([0,0,1])).

I hope it helps