Solved

Batch File: Backup Files with Has-Been folder

Posted on 2010-08-15
16
424 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
16 Comments
 
LVL 11

Accepted Solution

by:
Ben Personick 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 11

Expert Comment

by:Ben Personick
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
 
LVL 10

Author Comment

by:ReneGe
ID: 33442064
This will run on Windows Server 2003
0
 
LVL 11

Expert Comment

by:Ben Personick
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 11

Expert Comment

by:Ben Personick
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 11

Expert Comment

by:Ben Personick
ID: 33442076
I don;t understand what you mean by the hasbeen folder?

arent you copying source--> hasbeen folder, and stopping there?
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 33442082
trying to have real-time conversations on EE is annoying XD
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 51

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 11

Expert Comment

by:Ben Personick
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now