Question

Is it possible to download files of application to my local PC, i.e. perform operation opposite to "push"?

Was it helpful?

Solution 3

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

OTHER TIPS

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.

https://github.com/cloudfoundry-incubator/cflocal

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

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:

  1. Enable the ssh in you IBM app
  2. Get the SSH host
  3. Get the user
  4. 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.

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

https://gist.github.com/danhigham/4705713

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top