swisscomdev

How can I move an app from one space to another?


I have created a new space in the organisation and I have to move several apps from one space to the newly created one. How can I do this? (I don't want to rename the old space since only a subset of its apps need to be moved.


Solution

  • I'm afraid there is no such function to move apps from one space to another. There are two possibilities to achieve it, though:

    Compile & Push

    If you have access to the source-code of the app and use a common CI/CD setup, simply adjust your scripts, have them point to the new space and trigger a complete CI/CD cycle.

    Download & Push

    If you don't have access to the source-code, the binary-repository where you store your binaries or have to ensure it is 100% the same droplet in the new space, you can download that droplet from Cloud Foundry and push it to the new space:

    1. cf app source-app --guid to get your source app guid
    2. cf curl /v2/apps/:source-guid/droplet/download --output /tmp/droplet.tgz to download the source app's droplet to your local machine (note that if your Cloud Controller is configured to use a remote blobstore this command will return a redirect to the actual location of the droplet)
    3. cf target -s destination-space to target the space you want to push the copied droplet to
    4. cf push --droplet /tmp/droplet.tgz destination-app-name

    Credits: Github

    This will work for buildpack-based apps but not for Docker-based apps, as you can't simply download docker-binaries.

    Pitfall: If you want to use the same route again, don't forget to delete (not just unbind) it from your old space.