95 lines
2.6 KiB
Plaintext
95 lines
2.6 KiB
Plaintext
|
apiVersion: v1
|
||
|
kind: Pod
|
||
|
metadata:
|
||
|
name: restore-to-file
|
||
|
namespace: longhorn-system
|
||
|
spec:
|
||
|
nodeName: <NODE_NAME>
|
||
|
initContainers:
|
||
|
- name: prime-base-image
|
||
|
# set base image here
|
||
|
command:
|
||
|
- /bin/sh
|
||
|
- -c
|
||
|
- echo primed-base-image
|
||
|
# set base image here
|
||
|
image: <BASE_IMAGE>
|
||
|
imagePullPolicy: Always
|
||
|
containers:
|
||
|
- name: base-image
|
||
|
command:
|
||
|
- /bin/sh
|
||
|
- -c
|
||
|
- mkdir -p /share/base_image &&
|
||
|
mount --bind /base_image/ /share/base_image &&
|
||
|
echo base image mounted at /share/base_image &&
|
||
|
trap 'umount /share/base_image && echo unmounted' TERM &&
|
||
|
while true; do $(ls /talk/done 2>&1); if [ $? -eq 0 ]; then break;
|
||
|
fi; echo waiting; sleep 1; done;
|
||
|
umount /share/base_image && echo unmounted
|
||
|
# set base image here
|
||
|
image: <BASE_IMAGE>
|
||
|
imagePullPolicy: IfNotPresent
|
||
|
securityContext:
|
||
|
privileged: true
|
||
|
volumeMounts:
|
||
|
- name: share
|
||
|
mountPath: /share
|
||
|
mountPropagation: Bidirectional
|
||
|
- name: talk
|
||
|
mountPath: /talk
|
||
|
- name: restore-to-file
|
||
|
command:
|
||
|
# set restore-to-file arguments here
|
||
|
- /bin/sh
|
||
|
- -c
|
||
|
- while true; do list=$(ls /share/base_image/* 2>&1); if [ $? -eq 0 ]; then break;
|
||
|
fi; echo waiting; sleep 1; done; echo Directory found $list;
|
||
|
longhorn backup restore-to-file
|
||
|
'<BACKUP_URL>'
|
||
|
--backing-file $list
|
||
|
--output-file '/tmp/restore/<OUTPUT_FILE>'
|
||
|
--output-format <OUTPUT_FORMAT>
|
||
|
&& touch /talk/done && chmod 777 /talk/done && echo created /share/done
|
||
|
# the version of longhorn engine should be v0.4.1 or higher
|
||
|
image: rancher/longhorn-engine:v0.4.1
|
||
|
imagePullPolicy: IfNotPresent
|
||
|
securityContext:
|
||
|
privileged: true
|
||
|
volumeMounts:
|
||
|
- name: share
|
||
|
mountPath: /share
|
||
|
mountPropagation: HostToContainer
|
||
|
readOnly: true
|
||
|
- name: talk
|
||
|
mountPath: /talk
|
||
|
- name: disk-directory
|
||
|
mountPath: /tmp/restore # the argument <output-file> should be in this directory
|
||
|
env:
|
||
|
# set Backup Target Credential Secret here.
|
||
|
- name: AWS_ACCESS_KEY_ID
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
name: <S3_SECRET_NAME>
|
||
|
key: AWS_ACCESS_KEY_ID
|
||
|
- name: AWS_SECRET_ACCESS_KEY
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
name: <S3_SECRET_NAME>
|
||
|
key: AWS_SECRET_ACCESS_KEY
|
||
|
- name: AWS_ENDPOINTS
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
name: <S3_SECRET_NAME>
|
||
|
key: AWS_ENDPOINTS
|
||
|
volumes:
|
||
|
- name: share
|
||
|
emptyDir: {}
|
||
|
- name: talk
|
||
|
emptyDir: {}
|
||
|
# the output file can be found on this host path
|
||
|
- name: disk-directory
|
||
|
hostPath:
|
||
|
path: /tmp/restore
|
||
|
restartPolicy: Never
|