Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

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
0
ReneGe
Asked:
ReneGe
2 Solutions
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
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
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
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
 
ReneGeAuthor Commented:
Hey QCubec,

And what about the Has-Been Folder?

Cheers,
Rene
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ReneGeAuthor Commented:
This will run on Windows Server 2003
0
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
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
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
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
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
I don;t understand what you mean by the hasbeen folder?

arent you copying source--> hasbeen folder, and stopping there?
0
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
trying to have real-time conversations on EE is annoying XD
0
 
ReneGeAuthor Commented:
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
 
ReneGeAuthor Commented:
Also, since Robocopy seems to be able et copy the Time Stamp, as you suggested, I defenatly will need to use Robocopy.
0
 
Steve KnightIT ConsultancyCommented:
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
 
ReneGeAuthor Commented:
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
 
ReneGeAuthor Commented:
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
 
Bill PrewCommented:
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
 
ReneGeAuthor Commented:
;-)
0
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now