Can I restore my source code that has been uploaded into Google AppEngine?

前端 未结 8 1638
旧巷少年郎
旧巷少年郎 2020-11-30 04:57

I recently had a hard drive crashed and lost all of my source code. Is it possible to pull/checkout the code that I have already uploaded to Google App Engine (like the most

相关标签:
8条回答
  • 2020-11-30 05:31

    You have to revert to the earlier sdk, appcfg.py is not in the latest sdk. Kind of a pain, but it works. It should be far more prominent in the literature. Cost me an entire day.

    0 讨论(0)
  • 2020-11-30 05:32

    Update: Google appengine now allows you to download the code (for Python, Java, PHP and Go apps)

    Tool documentation here.

    0 讨论(0)
  • 2020-11-30 05:40

    You CAN get your code, even in Java. It just requires a bit of reverse engineering. You can download the war file using the appengine SDK by following these instructions: https://developers.google.com/appengine/docs/java/tools/uploadinganapp

    Then you at least have the class files that you can run through JAD to get back to the source files (close to it, at least).

    0 讨论(0)
  • 2020-11-30 05:44

    Update as of October 2020.

    The current version of the Google App Engine SDK still includes the appcfg.py script however when trying to download the files from your site the script will attempt to download them into the root folder of your system.

    Example:

    /images/some_site_image.png
    

    This is probably related to changes in appengine where your files might have been in a relative directory before but they are no longer with the new versions of the system.

    To fix the problem you will have to edit the appcfg.py file in:

    <path_to_cloud_install_dir>/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg.py
    

    Around line 1634 you will find something that looks like:

    full_path = os.path.join(out_dir, path)
    

    The problem is with the path argument that for most files is a root directory. This causes the join method to ignore the out_dir argument.

    To fix this on a *NIX and MacOS type of system you will need to add a line before the above mentioned statement that looks like:

    path = re.sub(r'^/', '', path)
    

    This removes the '/' prefix from the path and allows the join method to properly connect the strings.

    Now you should be able to run:

    google-cloud-sdk/platform/google_appengine/appcfg.py download_app -A <app> -V <version> 20200813t184800 <your_directory>
    
    0 讨论(0)
  • 2020-11-30 05:53

    Unfortunately the answer is no. This is a common question on SO and the app engine boards. See here and here for example.

    I'm sure you'll be OK though, because you do keep all your code in source control, right? ;)

    If you want this to be an option in the future, you can upload a zip of your src, with a link to it somewhere in your web app, as part of your build/deploy process.

    There are also projects out there like this one that automate that process for you.

    0 讨论(0)
  • 2020-11-30 05:53

    if you're using python... you might be able to write a script that opens all the files in it's current directory and child directories and adds them to a zipfile for you to download

    I don't know much about app engine or the permissions, but it seems like that could be possible

    0 讨论(0)
提交回复
热议问题