sejal goyal
sejal goyal

Reputation: 23

How to obtain output files from cloudfoundry that deployed application has created?

I have deployed a windows exe on cloudfoundry, now i want to get back the files from cloudfoundry that exe has generated. Is there any way of retrieving files using a batch script?

Upvotes: 0

Views: 311

Answers (1)

Daniel Mikusa
Daniel Mikusa

Reputation: 15051

It's important to note that you don't write anything of critical to the local file system. The local file system is ephemeral so if your app crashes/restarts for any reason before you obtain the files then they are gone.

Having said that, if you have an application that is doing some processing and generating output files, the recommended way to handle this would be to have the process write those files somewhere external and durable, like a database, SFTP server or S3-compatible service. In short, push the files out somewhere, instead of trying to get into the container to obtain the files.


If you must pull them out of the container, you have a couple options:

  1. Run a small HTTP server in the container & expose the files on it. Make sure you are appropriately securing the server to prevent unauthorized access to your files.

  2. Run scp or sftp and download the files. Instructions for doing that can be found here, but roughly speaking you run cf app app-name --guid to get the app guid, cf ssh-code to get a passcode, then scp -P 2222 -oUser=cf:<insert app-guid>/0 ssh.system_domain:my-remote-file.json ./ to get the file named my-remote-file.json. Obviously, change the path/file to what you want to download.

Upvotes: 2

Related Questions