How do I retrieve my App Engine app's source c

2020-07-31 10:19发布

问题:

I've migrated to a new system and lost my local copy of my App Engine app. Foolishly, I didn't use source control.

I know I've used the gcloud tool to retrieve the source code of my project in the past, but I don't seem to be able to find how to do it again. Everything I find points toward how to use appcfg.py, which didn't come with gcloud. I know I've used gcloud for this purpose before with no issues, though, so I'm perplexed as to how I can't find the command anymore.

Furthermore, this answer about using Cloud Build doesn't work for me - Cloud Build was not and is not enabled.

回答1:

In the past, one was able to download the source code for the deployed app using the command:

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

(see this thread gcloud: how to download the app via cli).

However, the command gcloud preview app modules download has since been deprecated (as Zachary Newman relayed here - see also the Google Cloud SDK Release Notes for version 92.0.0 (2016-1-13) in the “Breaking Changes” section: “Removed deprecated gcloud preview app modules download command.”).

Currently, appcfg.py is the recommended way to go, and you can invoke that command either:

  • from the Cloud Shell, or,
  • directly from the installed Cloud SDK subfolder /google-cloud-sdk/platform/google_appengine/

This article shows in detail how to download the source code by using the appcfg.py command, and you can also enter appcfg.py download_app --help or check this answer for more details on how to retrieve the source code for specific services/modules and versions.

I would also add that you can see the deployed source code of your application in the Stackdriver Debugger panel of the Cloud Console.