If judgment is not recovered by the plaintiff, all the property attached, or the proceeds thereof, or the undertaking thereof, shall be returned to the defendant upon his serving upon the marshal a certified copy of the order discharging the attachment.