Copy files from last deployment

We have user uploaded files that we need to copy from one deployment to the next. What is the best way to accomplish that?

More info:
We have an uploads folder that user’s upload files to. But when we roll out a new deployment, the uploads folder is empty. We need a way to copy those files to the new deployment.

I’m thinking we need some post deploy script but how would we know what the last deployment folder was?

Hi Brian,

Thanks for getting in touch!
There are two variables here that could help Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory or Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath depending on your setup.
HOWEVER I feel this needs a warning, if the deployment was successful but was rolled back for whatever reason you might not get the correct path.

May I ask why you your user uploads directory is not outside of the deployment process? IE somewhere static so files do not have to be continually moved?

Cheers!
Vanessa

Hi Vanessa,

We use Umbraco. It stores uploaded content in a folder called media off the
website root. I’m not aware of a way to store that folder elsewhere. Is
there a way in Octopus to setup a virtual directory in IIS under the main
website that could point to a folder outside the website?

Cheers,

Brian

Hi Brian,

Well, the two ways that Octopus could resolve this are:

  1. We have a step template for Virtual Directories that you could use
  2. Use the Custom Installation Folder feature and always deploy to the same location thus never needing to move your uploaded files again.

For either case you might have reasons to not want to use them, thus you can use the variables below to write something, but maybe they will help to make a smoother release for you.
Vanessa

How can:

How can:

Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath

…be used when multiple child steps are deploying. Each child step deploys a different package to different locations on the server(s).

Hi Jesse,

Thanks for getting in touch!
You should just be able to use it as is. It will be referenced to the correct machine for a child step.
(This is assuming you want it within the package step and not outside of it?)

Vanessa

Thanks I will give it a shot.