Is it necessary to use NFS for local backups?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 本地备份一定要用nfs吗?

| username: TiDBer_djgos04V

[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?

| username: 像风一样的男子 | Original post link

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.

| username: TiDBer_djgos04V | Original post link

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.

| username: 啦啦啦啦啦 | Original post link

Could you send the backup command?

| username: 像风一样的男子 | Original post link

Are the file directories the same? Have you set the permissions to 777?

| username: TiDBer_djgos04V | Original post link

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.

| username: 大飞哥online | Original post link

The image you provided is not visible. Please provide the text you need translated.

| username: TiDBer_djgos04V | Original post link

No problem, it was my own stupidity, I gave permissions to the parent directory :joy:

| username: 大飞哥online | Original post link

/tmp/tidb-backup/snapshot-20230906100000 777 root:root Full permissions given

| username: TiDBer_djgos04V | Original post link

So I would like to ask, how should I merge during backup? Where should I place the files generated under tikv?

| username: tidb菜鸟一只 | Original post link

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.

| username: TiDBer_djgos04V | Original post link

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?

| username: 大飞哥online | Original post link

Yes, during the restoration, each TiKV directory must have all the backup data.

| username: zhanggame1 | Original post link

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.

| username: zhanggame1 | Original post link

Merging means copying to the same directory, and the file names will not conflict.

| username: Kongdom | Original post link

Can’t you mount the directory?

| username: Fly-bird | Original post link

As long as all KV nodes can access this disk, it will be fine.

| username: tidb菜鸟一只 | Original post link

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.

| username: 随缘天空 | Original post link

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.

| username: TiDBer_vfJBUcxl | Original post link

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.