Link to home
Start Free TrialLog in
Avatar of ReneGe
ReneGeFlag for Canada

asked on

Batch File: Backup Files with Has-Been folder

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
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
Avatar of ReneGe

ASKER

Hey QCubec,

And what about the Has-Been Folder?

Cheers,
Rene
Avatar of ReneGe

ASKER

This will run on Windows Server 2003
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.
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.
I don;t understand what you mean by the hasbeen folder?

arent you copying source--> hasbeen folder, and stopping there?
trying to have real-time conversations on EE is annoying XD
Avatar of ReneGe

ASKER

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
Avatar of ReneGe

ASKER

Also, since Robocopy seems to be able et copy the Time Stamp, as you suggested, I defenatly will need to use Robocopy.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ReneGe

ASKER

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
Avatar of ReneGe

ASKER

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
Avatar of Bill Prew
Bill Prew

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
Avatar of ReneGe

ASKER

;-)
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.