We have Windows 2012 R2 AWS ec2 instance where there is a particular folder structure created for a COTS application. We have built fault tolerance and any time this instance goes down and another ones comes up, the new instance installs everything from scratch. The challenge is, copying the folder structure into the new one. The folder structure is quite deep (5 level) and I would like to avoid manually create these 100's of folder structure when the new instance is coming up.
To Illustrate, my current ec2 has:
C:\ABC
C:\ABC\sub1
C:\ABC\sub2
...
C:\ABC\subn
C:\ABC\sub1\child1-sub1
C:\ABC\sub1\child2-sub1
...
C:\ABC\sub2\child1-sub2
C:\ABC\sub2\child2-sub2
...
so on..
My idea is if I can copy the folder structure (without files) into a variable, then I can write the variable into a file and I can copy the file into S3. When the new instance comes up, read this file from S3, get the structure and re-create it.
I tried using " robocopy $source $dest /e /xf *.*"
, but $dest
is a directory. I need to store the results into some kind of variable which can be stored somewhere.
Any suggestions/ thoughts?