Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preserve folder hierarchy

Status
Not open for further replies.

Steel811

Programmer
Jan 2, 2008
26
0
0
US
Hello all,

I am writing a script that is making updates to a webpage based on an input file, which contains the full path to the file being updated in both dev and prod. What I want to do is prior to copying what is in dev to prod is copy the current file in prod to a backup directory, but at the same time preserving the folder structure. Does anyone know how this could be done? As you will see below, the number of subfolders is not static, but the document root for the site is. See below for an example of the input file:

c,c:\webroot\d,c:\webroot\
Any help is greatly appreciated!
Sheel
 
Have you thought of using Robocopy instead of creating your own solution?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
To be honest, I didn't think of using robocopy.

Please confirm the options I would want to use:

/E to account for any subfolders, if what I need to copy over is a folder.

/CREATE which creates the directory tree structure?

or

/FP - full path name

Please confirm. Thanks for your help EBGREEN!
Sheel
 
You would really need to play around in a sandbox to get the exact behavior that you want but /MIR is generally where I start.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I haven't been able to find the options necessary. /MIR didn't even do what I wanted to. So far, the only solution i have been able to find for this is by zipping up the file/folder being backed up.

Can anyone else think of other ways?

Thanks in advance,
Sheel
 
so if you are wanting to backup your production environment, wouldn't you want all the files in the directory tree instead of just one file?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
No, as this is for a content deployment system. Whenever a change is made to an existing page, we don't want to back up the entire directory tree every single time, which consists of thousands of files. We just want to back up that one file, and also have the folder structure to that file.
 
7Zip might be a good option. It has a command line interface and it is free.

Simi
 
But you see that is exactlt what robocopy does. You give it the root folder and tell it to recurse and it will just copy changed files.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
If you are only wanting to backup one file, how does the directory structure change?

Isn't it always in the same place?

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top