?
Solved

script needed

Posted on 2014-01-17
8
Medium Priority
?
277 Views
Last Modified: 2014-04-29
I have a windows 2008 server that has a directory called D:\Vault backups
inside of this directory is a backup that occurs every night M-F.
I need to move the contents of the backup folder into another directory call Vaultlogix where it will be backed up to the cloud.
THe problem is that the backup directory under D:\vault backups recreates itself every night with a different day and time stamp that are not consistent. THe date stamp is, but the time stamp varies. So for example, here is the name of the current backup directory:
Vaultbackup_2014_01_16_11_00_09_PM.
I need to move the contents of that folder to the vaultlogix folder and then delete empty date and time stamped directory that is left in the original location.
Can I do this with a batch file or some sort of a script?
0
Comment
  • 5
  • 2
8 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 1500 total points
ID: 39790101
You can use robocopy to accomplish this. Take a look at a PAQ that I answered with similar requirements that you have. See link below...

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/Q_28258952.html

Will.
0
 

Author Comment

by:williamstechnologygroup
ID: 39790108
i got robocopy to work with a static folder name, but my challenge is how do I enter a variable to let robocopy know that it is to move the contents of the folder whose name begins with "vaultbackup" because the rest of the directory name is going to change daily and I need to have some type of wildcard entry that lets robocopy know to look in the directory that starts with that name...
0
 

Author Comment

by:williamstechnologygroup
ID: 39790109
i think i am close with this link, but still dont' know what i am doing
http://www.tomshardware.com/forum/69008-63-folder-wildcard
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 18

Expert Comment

by:Steven Harris
ID: 39790142
Although Robocopy is popular and easy to use, I tend to lean towards PowerShell's copy-item, but I think we still need some more info.  What is the full path of the source and destinations?  Such as:

"D:\Vault Backup\Vaultbackup_2014_01_16_11_00_09_PM"

and

"E:\VaultLogix"

In this case, you could use:

copy-item "D:\Vault Backup\Vaultbackup*\*.*" "E:\VaultLogix"
0
 

Author Comment

by:williamstechnologygroup
ID: 39790886
ok, we are geting closer now. Does Powershell have a utility/command for MOVING the data? It needs to be relocated to a different directory on the same disk partition. It is over 30 gb so I don't want to copy it. Plus I want to make sure that when it move the contents of the "Vaultbackup_2014_01_16_11_00_09_PM" folder, that it removes the empty parent folder altogether from it's original location. That way when the next backup kicks in and gets copied to the "vault backup" folder it does not have to worry about overwriting anything which at this point the backup utility cannot do.
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39791033
This is going to be a long post, so bare with me here...

Does Powershell have a utility/command for MOVING the data? It needs to be relocated to a different directory on the same disk partition. It is over 30 gb so I don't want to copy it.
Sure!  Easy enough, we just change it to move-item.

Plus I want to make sure that when it move the contents of the "Vaultbackup_2014_01_16_11_00_09_PM" folder, that it removes the empty parent folder altogether from it's original location.
Just to make sure I understand your statement here:

This should be similar to what you see now:
The folder/files exist in the SOURCE, but not in the DESTINATION
Before ScriptAfter you run the script, this is the outcome:
The folder/files now reside in the DESTINATION and are removed from the SOURCE
After Script
In short, the script is just automating the Cut/Paste functionally.

If all of the above is correct, then perform a test using the following:

Move-Item "D:\Vault Backup\Vaultbackup*" "E:\VaultLogix" -whatIf

Open in new window


"D:\Vault Backup\Vaultbackup*" - will look for any folder starting with "Vaultbackup..."

The whatIf will describe the command, without actually executing it.  Such as:
PS> Move-Item "D:\Vault Backup\Vaultbackup*" "E:\VaultLogix" -WhatIf
What if: Performing the operation "Move Directory" on target "Item: C:\Vault Backup\Vaultbackup_2014_01_16_11_00_09_PM Destination: A:\VaultLogix\Vaultbackup_2014_01_16_11_00_09_PM".

Open in new window


If you are NOT wanting the actual folder moved, and just want the files, then we need to modify this a bit.
0
 

Author Comment

by:williamstechnologygroup
ID: 39793429
We do need to modify it.
The initial backup that is run creates the folder called "Vaultbackup_2014_01_16_11_00_09_PM" -- inside of that folder are the files and subfolders that need to be moved to the destination location (vaultlogix folder)-- where it will then be backed up to the cloud.
THe cloud backup system requires that the source folder's name is not a variable or else it will think it is NEW data and back the whole thing up to the cloud again. Which is why we must not move the parent folder with the date/time stamp  (Vaultbackup_2014_01_16_11_00_09_PM).
So i guess I need to be able to do 2 things:
1. move the contents of the time stamped folder to a different location
2. remove the time stamped (empty) folder once the move is completed so that the "vault backup" folder is now empty. I have to do this because the first backup that occurs does not have the ability to overwrite anything in the folder, it would just create a new folder with a new time stamp and so we would have 2 folders with very similar name (except for the date and time stamp) which would confuse the move script...
0
 

Author Closing Comment

by:williamstechnologygroup
ID: 40030925
I ended up using Robocopy in multiple bat files to accomplish the task.
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

OfficeMate Freezes on login or does not load after login credentials are input.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

569 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