Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 本地备份一定要用nfs吗?
[TiDB Usage Environment] Production Environment / Testing / PoC
A few days ago, while trying to back up TiDB, I found that there was always the following error when doing the backup locally:
When searching online for a solution, I found that NFS is needed, and after configuring it, the backup was indeed successful. Is it necessary to use NFS for local backups?
You can also back up to the local disk of the TiKV server, as long as the directory names are the same. However, after the backup, you need to merge the files in these directories for recovery, which is quite troublesome. Using an NFS shared disk eliminates the need for this file merging step.
I also tried creating the same directory on each TiKV server, but the issue still occurred during the backup, which is why I have this question.
Could you send the backup command?
Are the file directories the same? Have you set the permissions to 777?
Here is the backup command:
tiup br backup full --pd=“192.168.246.128:2379” --storage=‘local:///tmp/tidb-backup/snapshot-20230906100000’ --backupts=‘2023/09/06 10:00:00’
Permissions have also been granted to the file.
The image you provided is not visible. Please provide the text you need translated.
No problem, it was my own stupidity, I gave permissions to the parent directory 
/tmp/tidb-backup/snapshot-20230906100000 777 root:root Full permissions given
So I would like to ask, how should I merge during backup? Where should I place the files generated under tikv?
Merge all the files generated in the corresponding directories of all TiKV instances, and then put them back into the corresponding directories of all TiKV instances.
Does it mean that originally each part only had one-third of the content, but during recovery, each TiKV node needs to have the entire content?
Yes, during the restoration, each TiKV directory must have all the backup data.
Backup can be done without NFS, and restoration can also be done without it.
It requires all TiKV nodes to have the same backup path and write permissions.
For local backup restoration, you need to merge the backup data from all TiKV nodes. Each TiKV node should have a complete set of data. If the data volume is not large, you can use SCP to handle it.
Merging means copying to the same directory, and the file names will not conflict.
Can’t you mount the directory?
As long as all KV nodes can access this disk, it will be fine.
Yes, because it is not certain which data each TiKV is responsible for recovering, every TiKV needs to be able to access all the data content.
Using NFS for local backups is a relatively reasonable solution. You can also back up to the local directory on the TiKV machine. However, in a cluster environment, backing up data from multiple nodes only backs up the TiKV data of the local machine. For data recovery, you need to use the data from all TiKV nodes. At this point, you need to merge the data from all nodes and then transfer it to each TiKV node separately. This operation is complex, difficult to maintain, and prone to errors. Additionally, setting up an S3 storage service is also a good solution.
NFS is a solution for off-machine backup. Compared to backing up to the TiKV server, off-machine backup ensures that a complete backup is still available even if the TiKV server fails.