Solved

Batch File: Backup Files with Has-Been folder

Posted on 2010-08-15
16
434 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 13

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 13
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
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.

 
LVL 10

Author Comment

by:ReneGe
ID: 33442064
This will run on Windows Server 2003
0
 
LVL 13
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 13
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 13
ID: 33442076
I don;t understand what you mean by the hasbeen folder?

arent you copying source--> hasbeen folder, and stopping there?
0
 
LVL 13
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 56

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 13
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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
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 …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

623 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