Cluster information:
Kubernetes version: 1.17.0
Cloud being used: bare-metal
Installation method: apt-get?
Host OS: Debian 10
CNI and version: flannel:v0.11.0
CRI and version:
I am trying to develop a cron job that takes this rsync command:
“find /data/high-res/ -cmin +20 -printf %P\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/”
As of now, I am trying to pass it as an args in a kubernetes manifest file
args:
- /bin/sh
- -c
- "find /data/high-res/ -cmin +20 -printf %P\\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/"
Kubernetes interprets the
printf %P\\0
as
printf %P\0
.
If I add another backslash as an escape character, i.e.
%P\\\0
,
then it gets interpreted as
find /data/high-res/ -cmin +20 -printf %P\ | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/
What is the proper way to format the command so that it gets interpreted correctly?
I am attaching the entire yaml file below
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: highres-rsync-cronjob
spec:
schedule: "*/1 * * * *"
concurrencyPolicy: Replace
startingDeadlineSeconds: 10
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
containers:
- name: rsync-cronjob
image: raphaelcdm/highres-rsync-cronjob:v0.1.0
# command: ["/bin/sh", "-c", "find /data/high-res/ -cmin +20 -printf %P\\\0 \ | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/ --exclude '*_1.egg'"]
args:
- /bin/sh
- -c
- "find /data/high-res/ -cmin +20 -printf %P\\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/"
volumeMounts:
- name: local-storage
mountPath: /data/
- name: nfs-volume
mountPath: /mnt/
nodeSelector:
nfs_backup: ok
tolerations:
- key: is_fast_daq
operator: Exists
effect: NoSchedule
restartPolicy: OnFailure
volumes:
- name: local-storage
hostPath:
path: /data
type: Directory
- name: nfs-volume
nfs:
server: some.ip.address
path: /data
As a clarification: I am trying to implement this solution for my rsync needs: https://superuser.com/questions/1105059/how-to-rsync-files-older-than-x-min-on-linux