cancel
Showing results for 
Search instead for 
Did you mean: 

Cronjob to copy files from local to K8

Wishaal
8 - Cloud Apps
8 - Cloud Apps

Hi All,

Currently I am using the following

kubectl cp /home/ftpifx sisense/`kubectl -n sisense get po -l 'app=management' | awk 'END { print $1 }'`:/opt/sisense/storage/data/informix/

command to copy files between our local system and the storage pod.

However, we want to automate the run of this.

We tried creating a bash script and adding this to the Linux crontab, but this doesn't run.

Is there another way to run this command automatically? 

1 ACCEPTED SOLUTION

jirazazabal
9 - Travel Pro
9 - Travel Pro

Hi,

You just need to create a bash script in order to make the copy. First of all, get the management pod name:

#!/bin/bash

localFolder=/path/to/local/files
management=$(kubectl -n sisense get pods -l app="management" -o custom-columns=":.metadata.name")
for fileName in `find $localFolder -name '*.csv' -exec basename {} \;` ; do
        kubectl -n sisense cp /home/ftpifx sisense/$fileName $management:/opt/sisense/storage/data/informix/$fileName
done

Then, you can add this script to the corntab (make this .sh script executable)

Best

View solution in original post

2 REPLIES 2

jirazazabal
9 - Travel Pro
9 - Travel Pro

Hi,

You just need to create a bash script in order to make the copy. First of all, get the management pod name:

#!/bin/bash

localFolder=/path/to/local/files
management=$(kubectl -n sisense get pods -l app="management" -o custom-columns=":.metadata.name")
for fileName in `find $localFolder -name '*.csv' -exec basename {} \;` ; do
        kubectl -n sisense cp /home/ftpifx sisense/$fileName $management:/opt/sisense/storage/data/informix/$fileName
done

Then, you can add this script to the corntab (make this .sh script executable)

Best

Thank you very much @jirazazabal , this worked for me!