2

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.

Ethan McTague
  • 2,236
  • 3
  • 21
  • 53
  • If you're certain you used gcloud, check the logs in your local gcloud log dir (on linux it's `~/.config/gcloud/logs`), looking for ** Running** lines (like `2018-12-13 08:11:34,659 DEBUG root Running [gcloud.projects.get-iam-policy] with arguments: ...`) The portion in square brackets is the base CLI command, separated by dots. The cmd you seek should be between them (assuming the logs from that cmd's execution time are still around). – Dan Cornilescu Dec 17 '18 at 14:47
  • @DanCornilescu Sadly, I successfully used it on my previous setup, not this one. I think I've realized what the issue is, though - in my previous installation, I enabled the usage of experimental commands. It may have been one of those. – Ethan McTague Dec 17 '18 at 15:01
  • flexible env by any chance? – Dan Cornilescu Dec 17 '18 at 15:04
  • Some alternatives in case you don't find the `gcloud` cmd: https://stackoverflow.com/q/49181876/4495081 – Dan Cornilescu Dec 17 '18 at 15:08

1 Answers1

4

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.