All instruments of every kind, or attested copies thereof, by which a prisoner is committed or liberated, shall be regularly endorsed, filed, and safely kept by the sheriff or officer acting as jailer, and shall be delivered to his successor in office.
When a prisoner is confined by virtue of any process directed to the sheriff or other officer, and which shall require to be returned to the court whence it issued, such sheriff or officer shall keep a copy of the same, together with his return made thereon, which copy, duly certified by such sheriff or other officer, shall be prima facie evidence of his right to retain such prisoner in custody.
SDCL 24-11-17