## QuarkDB is replicated, do I really need backups?
Let's assume there's QuarkDB running at ```/var/lib/quarkdb``` - how to backup
this directory?
Yes, absolutely! Replication is very different from a backup. While
replication will most likely protect your data against a failing disk,
it will not protect from software bugs or other accidents.
First of all, it is a **bad** idea to directly copy the files of a running, live instance.
Please don't do that! Between the time you start the backup, to the time it finishes,
the underlying SST files will have likely changed, resulting in a backup that is corrupted.
## Cool, how to take a backup?
Instead, take a checkpoint by issuing ``raft-checkpoint /path/to/backup``,
which will create a point-in-time consistent snapshot, containing both state machine
and journal, from which you will be able to easily spin up another QDB instance if need be.
1. Create a point-in-time checkpoint by issuing ``quarkdb-checkpoint /path/to/backup`` redis command on the node you wish to backup. Both `state-machine` and `raft-journal` are included in the checkpoint.
Please make sure that ```/var/lib/quarkdb``` is on the **same** physical filesystem
as ```/path/to/backup```. This allows hard-linking the SST files, resulting in a
backup that takes virtually no additional space on the disk, and takes a couple
of seconds to create, even if your DB is half a terabyte.
2. Validate the newly created checkpoint using the command-line tool ``quarkdb-validate-checkpoint``.
After that, you should be able to stream or rsync this directory over the network.
Once you're done, make sure to **remove** it. Otherwise, the contents of ```/var/lib/quarkdb```
and ```/path/to/backup``` will soon start diverging as QDB processes more writes,
and new SST files are written. In short: ```/path/to/backup``` will no longer be
"for free", and start to consume actual disk space.
3. Stream or rsync the contents of `/path/to/backup` over the network to the intended long-term storage destination.
## Restore
4. Delete `/path/to/backup`.
Once we have a checkpoint, here are the steps to spin up an entirely new QuarkDB
instance out of it:
1. If the checkpoint was produced by a standalone instance, you can skip this
step. Otherwise, you need to change the hostname associated to the raft journal