Service robots are of paramount importance in both industrial and residential environments. Nevertheless, these robots frequently encounter obstacles in the form of perilous elements present in their surroundings, which may result in their malfunction and hinder their optimal performance. Hence, autonomous robot applications heavily rely on coverage path planning algorithms, which facilitate the execution of area coverage operations in a streamlined and economical manner. The article presents a coverage path planning algorithm for service robots that is based on a backtracking procedure. The proposed method attempts to strike a balance between the safety of the cleaning automaton and the extent of coverage. Following straight-forward instructions, the mobile robot (MR) initially generates a spiral or zigzag trajectory. It examines each position for possible backtracking locations. When obstacles and visited positions obstruct the path, the improved A* algorithm is utilized to return to known unvisited regions. Subsequently, the robot proceeds to sweep the regions until no remaining back-tracking sites remain. Simulation of the method on the Robot Operating System (ROS) verifies that it is possible to restrict the movement of high-risk robots.