mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
This commit adds support for Backup and Restore controller, which will be watching for
the events. The velero plugin will create a Backup CR to create a backup
with the remote location information, the controller will send the data
to that remote location.
In the same way, the velero plugin will create a Restore CR to restore the
volume from the the remote location and the restore controller will restore
the data.
Steps to use velero plugin for ZFS-LocalPV are :
1. install velero
2. add openebs plugin
velero plugin add openebs/velero-plugin:latest
3. Create the volumesnapshot location :
for full backup :-
```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
name: default
namespace: velero
spec:
provider: openebs.io/zfspv-blockstore
config:
bucket: velero
prefix: zfs
namespace: openebs
provider: aws
region: minio
s3ForcePathStyle: "true"
s3Url: http://minio.velero.svc:9000
```
for incremental backup :-
```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
name: default
namespace: velero
spec:
provider: openebs.io/zfspv-blockstore
config:
bucket: velero
prefix: zfs
backup: incremental
namespace: openebs
provider: aws
region: minio
s3ForcePathStyle: "true"
s3Url: http://minio.velero.svc:9000
```
4. Create backup
velero backup create my-backup --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-cloud-default --storage-location=default
5. Create Schedule
velero create schedule newschedule --schedule="*/1 * * * *" --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-local-default --storage-location=default
6. Restore from backup
velero restore create --from-backup my-backup --restore-volumes=true --namespace-mappings velero-ns:ns1
Signed-off-by: Pawan <pawan@mayadata.io>
136 lines
4.9 KiB
Bash
Executable file
136 lines
4.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Copyright 2019 The Kubernetes Authors.
|
|
# Copyright 2020 The OpenEBS Authors.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
## find or download controller-gen
|
|
CONTROLLER_GEN=$(which controller-gen)
|
|
|
|
if [ "$CONTROLLER_GEN" = "" ]
|
|
then
|
|
echo "ERROR: failed to get controller-gen, Please run make bootstrap to install it";
|
|
exit 1;
|
|
fi
|
|
|
|
$CONTROLLER_GEN crd:trivialVersions=false,preserveUnknownFields=false paths=./pkg/apis/... output:crd:artifacts:config=deploy/yamls
|
|
|
|
## create the the crd yamls
|
|
|
|
echo '
|
|
|
|
##############################################
|
|
########### ############
|
|
########### ZFSVolume CRD ############
|
|
########### ############
|
|
##############################################
|
|
|
|
# ZFSVolume CRD is autogenerated via `make manifests` command.
|
|
# Do the modification in the code and run the `make manifests` command
|
|
# to generate the CRD definition' > deploy/yamls/zfsvolume-crd.yaml
|
|
|
|
cat deploy/yamls/zfs.openebs.io_zfsvolumes.yaml >> deploy/yamls/zfsvolume-crd.yaml
|
|
rm deploy/yamls/zfs.openebs.io_zfsvolumes.yaml
|
|
|
|
echo '
|
|
|
|
##############################################
|
|
########### ############
|
|
########### ZFSSnapshot CRD ############
|
|
########### ############
|
|
##############################################
|
|
|
|
# ZFSSnapshot CRD is autogenerated via `make manifests` command.
|
|
# Do the modification in the code and run the `make manifests` command
|
|
# to generate the CRD definition' > deploy/yamls/zfssnapshot-crd.yaml
|
|
|
|
cat deploy/yamls/zfs.openebs.io_zfssnapshots.yaml >> deploy/yamls/zfssnapshot-crd.yaml
|
|
rm deploy/yamls/zfs.openebs.io_zfssnapshots.yaml
|
|
|
|
|
|
echo '
|
|
|
|
##############################################
|
|
########### ############
|
|
########### ZFSBackup CRD ############
|
|
########### ############
|
|
##############################################
|
|
|
|
# ZFSBackups CRD is autogenerated via `make manifests` command.
|
|
# Do the modification in the code and run the `make manifests` command
|
|
# to generate the CRD definition' > deploy/yamls/zfsbackup-crd.yaml
|
|
|
|
cat deploy/yamls/zfs.openebs.io_zfsbackups.yaml >> deploy/yamls/zfsbackup-crd.yaml
|
|
rm deploy/yamls/zfs.openebs.io_zfsbackups.yaml
|
|
|
|
|
|
echo '
|
|
|
|
##############################################
|
|
########### ############
|
|
########### ZFSRestore CRD ############
|
|
########### ############
|
|
##############################################
|
|
|
|
# ZFSRestores CRD is autogenerated via `make manifests` command.
|
|
# Do the modification in the code and run the `make manifests` command
|
|
# to generate the CRD definition' > deploy/yamls/zfsrestore-crd.yaml
|
|
|
|
cat deploy/yamls/zfs.openebs.io_zfsrestores.yaml >> deploy/yamls/zfsrestore-crd.yaml
|
|
rm deploy/yamls/zfs.openebs.io_zfsrestores.yaml
|
|
|
|
## create the operator file using all the yamls
|
|
|
|
echo '# This manifest is autogenerated via `make manifests` command
|
|
# Do the modification to the zfs-driver.yaml in directory deploy/yamls/
|
|
# and then run `make manifests` command
|
|
|
|
# This manifest deploys the OpenEBS ZFS control plane components,
|
|
# with associated CRs & RBAC rules.
|
|
' > deploy/zfs-operator.yaml
|
|
|
|
# Add namespace creation to the Operator yaml
|
|
cat deploy/yamls/namespace.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Add ZFSVolume v1alpha1 and v1 CRDs to the Operator yaml
|
|
cat deploy/yamls/zfsvolume-crd.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Add ZFSSnapshot v1alpha1 and v1 CRDs to the Operator yaml
|
|
cat deploy/yamls/zfssnapshot-crd.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Add ZFSBackup v1 CRDs to the Operator yaml
|
|
cat deploy/yamls/zfsbackup-crd.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Add ZFSRestore v1 CRDs to the Operator yaml
|
|
cat deploy/yamls/zfsrestore-crd.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Copy the base Operator yaml to CentOS 7 and 8 Operator yamls
|
|
cp deploy/zfs-operator.yaml deploy/operators/centos7/zfs-operator.yaml
|
|
cp deploy/zfs-operator.yaml deploy/operators/centos8/zfs-operator.yaml
|
|
|
|
# Add the ubuntu driver deployment to the Operator
|
|
cat deploy/yamls/ubuntu/zfs-driver.yaml >> deploy/zfs-operator.yaml
|
|
|
|
# Add the centos7 driver deployment to the Operator
|
|
cat deploy/yamls/centos7/zfs-driver.yaml >> deploy/operators/centos7/zfs-operator.yaml
|
|
|
|
# Add the centos8 driver deployment to the Operator
|
|
cat deploy/yamls/centos8/zfs-driver.yaml >> deploy/operators/centos8/zfs-operator.yaml
|
|
|
|
# To use your own boilerplate text use:
|
|
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
|