Solved

script needed

Posted on 2014-01-17
8
237 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
[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
  • 5
  • 2
8 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 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
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

OfficeMate Freezes on login or does not load after login credentials are input.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

710 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