If any defendant in attachment for a debt due shall, at any time before the return thereof, execute and deliver to the officer serving the same, a bond, with two or more sufficient sureties, to be approved by said officer, payable to the plaintiff in attachment, in a penalty double the amount claimed by the plaintiff, conditioned to pay and satisfy any judgment which may be recovered by the plaintiff in the suit, with all costs, the attachment shall be thereby discharged; and all the property of every kind levied on, attached or seized by virtue thereof, shall be released and restored to such defendant. The bond shall be returned with the attachment; and in case of any recovery by the plaintiff in the suit, judgment shall be entered against the defendant and the sureties in the said bond. After the return of the attachment, the bond herein provided for may be given at any time before final judgment, and may be taken by the sheriff, or officer by whom the attachment was served, in case any of the attached property remains in his hands; otherwise, by the clerk of the court in which the attachment is pending.