  The loss of qubits - the elementary carriers of quantum information - poses
one of the fundamental obstacles towards large-scale and fault-tolerant quantum
information processors. In this work, we experimentally demonstrate a complete
toolbox and the implementation of a full cycle of qubit loss detection and
correction on a minimal instance of a topological surface code. This includes a
quantum non-demolition measurement of a qubit loss event that conditionally
triggers a restoration procedure, mapping the logical qubit onto a new encoding
on the remaining qubits. The demonstrated methods, implemented here in a
trapped-ion quantum processor, are applicable to other quantum computing
architectures and codes, including leading 2D and 3D topological quantum error
correcting codes. These tools complement previously demonstrated techniques to
correct computational errors, and in combination constitute essential building
blocks for complete and scalable quantum error correction.
