Skip to content

Commit

Permalink
doc: Simplify the use of NFS backup.
Browse files Browse the repository at this point in the history
  • Loading branch information
runkecheng committed Apr 19, 2022
1 parent 971e974 commit 3761a8f
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 71 deletions.
90 changes: 52 additions & 38 deletions docs/deploy_backup_restore_nfs.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,76 @@
# mysql-operator

## Quickstart for NFS backup
### Create NFS server
First create your PVC, such as "neosan1",
Or use local storage pvc, see `config/sample/pv-claim.yaml`
and `pv-volume.yaml` for more details.
Then create NFS server, such as "nfs-server",
```yaml
fill it to `config/samples/nfs_rc.yaml `
```yaml
...
volumes:
- name: nfs-export-fast
persistentVolumeClaim:
claimName: neosan1 // or backup-pv-claim
# Quickstart for NFS backup
## Install NFS server

### 1. Prepare Storage

Create the NFS PV and SC.

```
kubectl apply -f config/samples/nfs_pv.yaml
```

> You can specify the PVC you created by modifying the `persistentVolumeClaim.claimName` in the `config/samples/nfs_server.yaml`.
### 2. Create nfs server

Create ReplicationController and Service.

```
```shell
# create the nfs pod
kubectl apply -f config/samples/nfs_rc.yaml
# create the nfs service
kubectl apply -f config/samples/nfs_server.yaml
```
if create the nfs server successful, get the then:
```

Get `NFSServerAddress`.

```
# example
kubectl get svc nfs-server --template={{.spec.clusterIP}}
10.96.253.82
```

## Create a NFS backup

### 1. Configure address of NFS Server.

## config `mysql_v1alpha1_backup.yaml ` and backup
Add field in `mysql_v1alpha1_backup.yaml ` as follow:
```yaml
BackupToNFS: "IP of NFS server"
# config/samples/mysql_v1alpha1_backup.yaml
NFSServerAddress: "10.96.253.82"
```
use command as follow to backup
### 2. Create a backup
```shell
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml
```

> Notice: backup cr and mysqlcluster cr must be in the same namespace.
## Restore cluster from exist NFS backup
first, configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `restoreFromNFS` field:

Configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `nfsServerAddress` field and fill in your own configuration.

```yaml
....
...
restoreFrom: "sample_202196152239"
restoreFromNFS : 10.96.253.82
nfsServerAddress: 10.96.253.82
```
`sample_202196152239` is the nfs server backup path, change it to yours.
the `10.96.253.82` is the NFS server ip, change it to yours.
> Notice: you can find the `sample_202196152239` in the nfs_server pod, at `/exports` path
or find it in node `/mnt/backup` path if you use the local pesistent volume with `sample/pv-volume.yaml`.
> Notice: restoreFrom is the folder name of a backup. You can find it on the path mounted in NFS Server.
Create cluster from NFS server backup copy:
```
kubectl apply -f config/samples/mysql_v1alpha1_cluster.yaml
```

use command as follow to create cluster from NFS server backup copy:
## Build your own image

## build your own image
such as :
```
docker build -f Dockerfile.sidecar -t acekingke/sidecar:0.1 . && docker push acekingke/sidecar:0.1
docker build -t acekingke/controller:0.1 . && docker push acekingke/controller:0.1
```
you can replace acekingke/sidecar:0.1 with your own tag
> You can replace acekingke/sidecar:0.1 with your own tag
## deploy your own manager
## Deploy your own manager
```shell
make manifests
make install
Expand Down
92 changes: 59 additions & 33 deletions docs/en-us/deploy_backup_restore_s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,55 +112,81 @@ could restore a cluster from the `backup_2021720827 ` copy in the S3 bucket.

if you want backup to NFS server or restore from NFS server, do it as follow:

## Quickstart for NFS backup
## Quickstart for NFS backup
### Install NFS server

### Create NFS server
first create your PVC, such as "neosan1", fill it to `config/samples/nfs_rc.yaml `
```yaml
...
volumes:
- name: nfs-export-fast
persistentVolumeClaim:
claimName: neosan1
```
```shell
# create the nfs pod
kubectl apply -f config/samples/nfs_rc.yaml
# create the nfs service
#### 1. Prepare Storage

Create the NFS PV and SC.

```
kubectl apply -f config/samples/nfs_pv.yaml
```

> You can specify the PVC you created by modifying the `persistentVolumeClaim.claimName` in the `config/samples/nfs_server.yaml`.
#### 2. Create nfs server

Create ReplicationController and Service.

```
kubectl apply -f config/samples/nfs_server.yaml
```
if create the nfs server successful, get the then:
```

Get `NFSServerAddress`.

```
# example
kubectl get svc nfs-server --template={{.spec.clusterIP}}
10.96.253.82
```

### Create a NFS backup

#### 1. Configure address of NFS Server.

## config `mysql_v1alpha1_backup.yaml ` and backup
Add field in `mysql_v1alpha1_backup.yaml ` as follow:
```yaml
BackupToNFS: "IP of NFS server"
# config/samples/mysql_v1alpha1_backup.yaml
NFSServerAddress: "10.96.253.82"
```
use commadn as follow to backup
#### 2. Create a backup
```shell
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml
```

## Restore cluster from exist NFS backup
first, configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `restoreFromNFS` field:

> Notice: backup cr and mysqlcluster cr must be in the same namespace.
### Restore cluster from exist NFS backup

Configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `nfsServerAddress` field and fill in your own configuration.

```yaml
....
restoreFrom: "backup_202196152239"
restoreFromNFS : 10.96.253.82
...
restoreFrom: "sample_202196152239"
nfsServerAddress: 10.96.253.82
```
`backup_202196152239` is the nfs server backup path, change it to yours.
the `10.96.253.82` is the NFS server ip, change it to yours.
use command as follow to create cluster from NFS server backup copy:
> Notice: restoreFrom is the folder name of a backup. You can find it on the path mounted in NFS Server.
Create cluster from NFS server backup copy:
```
kubectl apply -f config/samples/mysql_v1alpha1_cluster.yaml
```

### Build your own image

## build your own image
such as :
```
docker build -f Dockerfile.sidecar -t acekingke/sidecar:0.1 . && docker push acekingke/sidecar:0.1
docker build -t acekingke/controller:0.1 . && docker push acekingke/controller:0.1
```
you can replace acekingke/sidecar:0.1 with your own tag

## deploy your own manager
> You can replace acekingke/sidecar:0.1 with your own tag
### Deploy your own manager

```shell
make manifests
make install
Expand Down

0 comments on commit 3761a8f

Please sign in to comment.