I would like to retrieve some application's logs.
I found that the command cf file
was not available anymore and the plugin cf-download
doesn't work on Diego Architecture.
Is there a way to retrieve files from the cloud foundry by CLI other another method?
3
votes
2 Answers
0
votes
The solution is to use SSH without cf CLI
When you are at the step 4) you can use WinSCP (for Windows) to have a graphical interface to navigate in the folders.
0
votes
A simpler albeit uncloudy / hacky solution is to use cf ssh
to transfer via stdout.
For example, if you want to transfer all files directly under /home/vcap/logs
you can do...
Update: Here's the much simpler and faster version without a for loop using only tar
:
cf ssh <APP> -i <INSTANCE> -c 'tar cfz - logs/*.log' | tar xfz - -C .
In my case this transfers 1 GB log files in just under 20 seconds.
Original answer:
#!/bin/sh
mkdir -p logs
for f in $( cf ssh <APP> -i <INSTANCE> -c 'ls logs/*' ); do
cf ssh <APP> -i <INSTANCE> -c "cat $f" > $f
done
In my setup this took about 11 minutes to transfer 1.3GB of log files.
Using gzip
compression brought this down to 5 minutes (replace the line in the for loop):
cf ssh <APP> -i <INSTANCE> -c "cat $f | gzip -c" | gunzip > $f
Pretty sure this can be optimized using tar
and getting rid of the for loop.
cf ssh
or native SSH client. See docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html – Josefine