Jenkins Helm, How do I run cronjob which runs Copy from container folder to mounted drive

Hi all,

I have jenkins pod running, i have folder inside container /var/log/folder
now i want to take backup of that folder and send it to the drive i mounted inside container. But unfortunately sudo doesnt work, crontab doesnt work. in Jenkins helm jenkins-4.2.15

Anyone has idea ?

generally doesn’t work inside of docker containers.

do you need root to access that directory? If so, you can take a look at bash - Exec commands on kubernetes pods with root access - Stack Overflow and see if any of the options there will help.

You can use kubectl cp/exec to copy files out.

1 Like

THis helped me. I am able to create cronjob on etcd nodes.

kubectl exec -it --namespace=jenkins jenkins-0 – bash -c "cp -R /var/log/folder /mnt/cdrive/builds"

Hope this will help other people :).

1 Like

Thanks a lot for your feedback. :pray: