Is it possible to download files of application to my local PC, i.e. perform operation opposite to "push"?
5 Answers
As long as your application finished staging successfully (i.e. the build pack ran and finished), you should be able to download the droplet that was built by CF. That will contain amongst other things your application code.
Ex:
$ cf app <app-name> --guid
2836d5fe-35f7-4409-b27b-4ed308152bb4
$ cf curl /v2/apps/2836d5fe-35f7-4409-b27b-4ed308152bb4/droplet/download --output my-droplet
See also https://apidocs.cloudfoundry.org/2.6.0/apps/downloads_the_bits_for_an_app.html & http://v3-apidocs.cloudfoundry.org/version/3.50.0/#download-package-bits
UPDATE (10/2/2019)
Make sure you use the --output
flag of cf curl
. If you simply redirect the output of cf curl
to a file, you will end up with an extra end of line character on the end of your droplet (or other download). For binary downloads this can cause problems. Some tools simply ignore the extra character like tar
, but it will cause your app to fail if you upload a droplet using cf push --droplet
.
UPDATE (7/13/2018)
There is also now cf local
, which is a cf cli plugin that does several things. One of the things it allows you to do is easily export and import droplets. It's probably the easiest way to do this going forward.

- 13,716
- 1
- 22
- 28
-
I don't seem to have the `droplet` resource available: { "code": 10000, "description": "Unknown request", "error_code": "CF-NotFound" } – xverges Sep 22 '15 at 18:08
-
Try this. Since this would respond back with 302. And curl did not follow the redirect. Find your access token from ~/.cf/config.json and do a "wget --header='Authorization: your token' https://api.run.pivotal.io/v2/apps/7f4bb926-49d0-491b-a092-a06f1ddb7263/droplet/download – Shaozhen Ding Oct 06 '15 at 14:21
-
Once you get this file to download, how do I open it? Doesn't seem to open as a `.zip`. – bbodenmiller Jul 13 '18 at 01:59
-
It's an archive, I can't recall if it's a zip or tar gzip. If you run `file
` it'll tell you. Or if you're on Windows, you could just try opening it with an archive/extraction app. It'll probably detect the right format. – Daniel Mikusa Jul 13 '18 at 17:25 -
Thank you! The curl command was the only thing that worked for me on the `Diego` backend. For me (on Windows 7), the downloaded file was a tar ball (so, `tar xvzf my-droplet` will extract the files) – Ashutosh Jindal Jan 14 '19 at 09:58
-
https://v3-apidocs.cloudfoundry.org/version/3.127.0/index.html#download-droplet-bits – kinjelom Nov 07 '22 at 10:54
Recent versions of cf
(Cloud Foundry's command line interface) makes this simpler by using the download plugin: https://github.com/ibmjstart/cf-download
More details from one of the authors at http://blog.ibmjstart.net/2015/05/22/cf-download/
Edit As pointed out by Dharmi, this does not work with the Diego backend https://github.com/ibmjstart/cf-download/issues/12

- 4,608
- 1
- 39
- 60
-
Thanks, this worked great, even though it sounded like my computer was going to explode. – MBillau Mar 07 '16 at 03:46
-
4
I use this simple script to download all the log files in my app you can tweak it to get all the content within the app folder
mkdir -p <appName>/app/data/logs
for i in `cf files <appName> app/data/logs | awk '{print $1}'`;
do cf files <appName> app/data/logs/$i > <appName>/app/data/logs/$i; done

- 148
- 1
- 8
-
Apparently, this does not work any more (`cf version 6.12.2-24abed3-2015-07-15T14:20:44+00:00`). I am getting `cf: 'file' is not a registered command. See 'cf help'` – xverges Sep 28 '15 at 06:17
OK man. I had same trouble. The most simple way is SCP over SSH.
To turn this more simple as i can, i put the follow steps.
After all I supose that you already had the "Cf cli" installed on your enviroment. See how in: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
Now to login in Cloud foundry SSH we have some things to do:
- Enable the ssh in you IBM app
- Get the SSH host
- Get the user
- Get password
Step 01 - Enable SSH
See official references in: https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html
Open CMD or terminal write:
> cf login - it's goes like bla bla bla
> cf enable-ssh app-name
You realy want know the app name! It's basics...
Step 2 - Get the server host
Well... if i have to explain what is a ssh host, is better rollback from here. If not, run command (little joke):
cf curl /v2/info
"app_ssh_endpoint": "ssh.MY-DOMAIN.com:2222"
Result is a json with many attributes. Copy the field called "app_ssh_endpoint". Take a look that after ":" is the ssh port to fill in the Winscp form or terminal command.
Step 3 - Concatenate you username
The username has made of "cf:" + "GUID" + "/" + "InstanceID".
To get GUID run terminal command:
cf app MY-AWESOME-APP --guid
Return a long id like: abcdefab-1234-5678-abcd-1234abcd1234
The instance ID is the sequential number of you app instance. The first app instance becomes with "0".
So we have cf:my-guid-result/0 as user name.
Step 4 - Get temp password
This step retrive a single use pass. Is this! You only use once the pass. Buuuut... you can execute this command every time that you would connect to the server or execute commands.
To get pass run terminal command:
cf ssh-code
Return small password: abcdefab
After this i recomend:
If you desire to download a whole "app/" folder like me, compact this and download with winSCP graph interface or by terminal using "scp" command.
This isn't intuitive but it's possible to do. I wish you a good luck.

- 21
- 2
I wrote this Ruby Gist a while back, it should still work with a small few tweaks or as is..

- 3,974
- 16
- 15