Solved

Batch File: Backup Files with Has-Been folder

Posted on 2010-08-15
16
432 Views
Last Modified: 2012-06-27
Hi there,

I need to make a mirror backup batch file that will also move any files that are to be deleted or replaced at the backup folder, to a folder called Has-Been, by also keeping it's NTSF Security and Auditing features.

Since it is a mirror backup, folders structures must be respected for the Backup folder as well as for the Has-Been folder.

I'v worked on it and received great help from QCubed and billprew. Their contribution was very educative.  I took the lead on this, the script is getting to complicated and I'm loosing sight. So I closed the thread to give them the points because they worked hard. I am now trying a differant approach by giving you the lead. Hoping that maybe you know a way to do this that is a lot simplyer than how I was picturing it, or just by completing the script.


PLEASE REFER TO:
http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_26399261.html



Thanks for your help.

Cheers,
Rene
0
Comment
Question by:ReneGe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 12

Accepted Solution

by:
Ben Personick (Previously QCubed) earned 400 total points
ID: 33442054
oh, is that all you wanted?  lets make your life easier.  Use RoboCopy. =)

Robocopy will preserve directory structure file time stamps and even NT security if you like.  I use this for backups nearly exclusively.

At it's simplest to COPY with ALL File attributes including NTFS Security AND Auditing, you can use the following line:

ROBOCOPY "\\SOURCE\SHARE" "\\DESTINATION\SHARE" * /ZB /E /COPYALL
0
 
LVL 12
ID: 33442057
Also ReneGe, are you running on Windows Vista, or 7, or 2008? because if you run the command on one of those you can use this option /DCopy:T which will preserve Directory time-stamps (defualt robocopy (and windows) behavior is to set directories to the current time stamp)
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442058
Hey QCubec,

And what about the Has-Been Folder?

Cheers,
Rene
0
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
LVL 10

Author Comment

by:ReneGe
ID: 33442064
This will run on Windows Server 2003
0
 
LVL 12
ID: 33442066
I actually have a complex script I use to copy many files from many directories, and a very simple one to copy several types of files from many computers both utilizing Robocopy. If you want to do more than run a single command.

also note I suggest you use /Log+:[C:\Path\Filename.log] /NP to keep a record.
0
 
LVL 12
ID: 33442073
okay on WIndows Server 2003 you can;t use DCopy:T, but then no Windows Command in Server 2003 preserve directory times because copy commands will only create destination directories.  It's new functionality only available in the new OSs.
0
 
LVL 12
ID: 33442076
I don;t understand what you mean by the hasbeen folder?

arent you copying source--> hasbeen folder, and stopping there?
0
 
LVL 12
ID: 33442082
trying to have real-time conversations on EE is annoying XD
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442121
Thanks for suggesting to share your complexe script. I'm sure I'll learn from it.

Also, a very important feature for me here, is to make a backup of the files that are to be deleted or replaced during the mirror backup process.

FOR EXAMPLE:
D:\Documents\Site1\test.txt  ==> has been MODIFIED
>XCOPY /E /I /F /H /K /O /X /Y M:\Backup\Documents\Site1\test.txt F:\Has-Been\%date%\Documents\Site1\test.txt  
>XCOPY /E /I /F /H /K /O /X /Y D:\Documents\Site1\test.txt  M:\Backup\Documents\Site1\test.txt

D:\Documents\Site1\test.txt  ==> has been DELETED
>XCOPY /E /I /F /H /K /O /X /Y M:\Backup\Documents\Site1\test.txt F:\Has-Been\%date%\Documents\Site1\test.txt  
>DEL M:\Backup\Documents\Site1\test.txt
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442131
Also, since Robocopy seems to be able et copy the Time Stamp, as you suggested, I defenatly will need to use Robocopy.
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 100 total points
ID: 33442227
Have been listening on the old thread, not got much time to look at the mo.

Sounds very over complicated..... triggering a shadow copy "Previous version" and using Robocopy to sync two areas sounds like it might be worth considering and no need to specifically store the "has been" versions of things then?!

Steve
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442242
Hey Steve,

By using the Has-Been folder, I get to keep the previous versions for as long as I have storage.  So I do need the Has-Been copy.

==> Qcubed, "trying to have real-time conversations on EE is annoying XD" = Yes but that's what we have so far.


Cheers,
Rene
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442354
Ok, I found it.

Will use previous thread script and simplifying it by using:

"FOR /F "tokens=1,2 delims=-> " %%A in ('xcopy ".\Test1" ".\Test2" /L /F /Y /D') do (
   Robocopy... %%A to copy new or changed files to the HasBeen folder
   Robocopy... %%A to Mirror to %%B
)

I should be good here. I will post a new thread if I need some more help.

==> QCubed, it would be nice if you could post your suggested complex backup script,  as I am sure it will be very helpful and educative.


If I was was to fast to close this thread and you were working on some solutions, please post them as I am sure it will be very helpful and educative as well.

Thanks and cheers to Billprew (for the previous thread), QCubed and Steve,
Rene
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 33442679
Yup, was out of the house today so didn't get in on this one but you were in good hands.  Catch you next time...

~bp
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33442682
;-)
0
 
LVL 12
ID: 33443396
Hey, sorry I had to leave shortly after 6 PM so I had no chance to post back.  I'm glad that helped you. =)

I think I see what you wanted to do now:

Step1: Copy all data from the user to another directory as-is, don't delete anything from the source, or remove any missing files from the destination.

Step2: MOVE some Data from the User folder to a different location "Has Been" folder which meets some criteria.  DO not delete any data from HasBeen Folder.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question