Solved

script needed

Posted on 2014-01-17
8
235 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 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
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…

813 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

14 Experts available now in Live!

Get 1:1 Help Now