8

I depolyed an app with gcloud preview app deploy.

Is there a way to download it to an other local machine? How can I get the files? I tried it via ssh with no success (can't access the docker dir)

UPDATE: I found this:

gcloud preview app modules download default --version 1 --output-dir=my_dir

but it's not loading files

Log

Downloading module [default] to [my_dir/default]
Fetching file list from server...
|- Downloading [0] files...                                 -|
Christian Haller
  • 643
  • 1
  • 7
  • 16
  • `gcloud preview app modules download` is an artifact of the old-style AppEngine (i.e. not with Docker). It won't work with Docker-style apps. (We have that functionality coming, but while `gcloud app` is in preview mode, things will be spotty). – Zachary Newman Sep 09 '15 at 22:12

5 Answers5

18

I am coming to Google App Engine after two years, I see that they have made lots of improvements and added tons of features. But sadly, their documentation sometimes leaves much to be desired.

I used to download my code of the uploaded version with the appcfg.pyusing the following command.

appcfg.py download_app -A <app_id> -V <version> <output-dir>

But of course now that they have culminated everything in the gcloud shell where appcfg.py is not accessible.

However, the following method helped me to download the deployed code:

  1. Go the console and in to the Google App Engine.
  2. Select the project you want to work with.

  3. Once the project's dashboard opens, Click on the top right to open the built in console window.

    enter image description here

  4. Which should load the cloud shell at the bottom, now if you check appcfg.py is available to you to use in this VM.

    enter imagedescription her[2]

  5. Hence, use appcfg.py download_app -A <app_id> -V <version> <output-dir> to download the code.

  6. Now once you have the code in the desired folder, in order to download it on your local machine - You can open the docker code editor

    enter image description here

  7. Now here I assumed if I rightclicked and exported the desired folder it would work,

    enter image description here

    but instead it gave me the following error message.

    {"Error":"'concurrency' must be a number but it is [object Undefined]","Message":"'concurrency' must be a number but it is [object Undefined]"}
    
  8. So, I thought maybe it would play along nicely if the the folder was an archive. Go back to the cloud shell and using whatever utility you fancy make an archive of the folder

    zip -r mycode.zip mycode
    
  9. Go to the docker code editor, export and download.

    enter image description here

Now. Of course there might many more ways do it (hopefully) but this is what made sense to me after returning to Google App Engine after 2 years.

Guido
  • 46,642
  • 28
  • 120
  • 174
Amit Ahire
  • 303
  • 4
  • 10
3

Currently, the best way to do this is to pull the files out of Docker.

Put instance into self-managed mode, so that you can ssh into it:

$ gcloud preview app modules set-managed-by default --version 1 --self

Find the name of the instance:

$ gcloud compute instances list | grep gae-default-1

Copy it out of the Docker container, change the permissions, and copy it back to your local machine:

$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 'sudo docker cp gaeapp:/app /tmp'
$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 "chown -R $USER /tmp/app"
$ gcloud compute copy-files --zone=us-central1-f gae-default-1-1234:/tmp/app /tmp/
$ ls /tmp/app
Dockerfile
[...]
Zachary Newman
  • 20,014
  • 4
  • 39
  • 37
  • Thanks for your help Zachary! I'm getting a ssh timeout :( gcloud compute ssh --zone=us-central1-c gae-default-1-g5ol 'sudo docker cp gaeapp:/app /tmp' ssh: connect to host 104.154.73.30 port 22: Operation timed out ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints. – Christian Haller Sep 10 '15 at 09:28
  • What happens if you try the same thing from the [Cloud Console](https://cloud.google.com/console) (Compute > AppEngine > Instances, then find the name of an instance running the version of the app you want and hit SSH)? – Zachary Newman Sep 10 '15 at 14:37
  • The first command doesn't seem to be a valid command any more. – aidan Jan 27 '19 at 02:24
2

IMHO, the best option today (Aug 2018) is:

Under the main menu, under Products, go to Tools -> Cloud Build -> Build history.

There, click the ID of the build you want.

Then, in the opened window (Build details), click the source link, the download of your compressed code begins.

As simple as that.

HTH.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Dovi Lilling
  • 91
  • 1
  • 2
0

As of Feb 2021, you can install appengine-sdk using pip

pip install appengine-sdk

Once installed, appcfg can be used to download the app code.

python -m appcfg download_app -A app_id [ -V version ] out-dir

0

Nothing works. Finally I found the source code this way. Simply go to google cloud storage. choose buckets starting with us.artifacts...., select containers > images > download the latest one (look by created date). unzip after downloaded file. it will have all the deployed source code of app engine.

Umesh Shaw
  • 11
  • 2