Solved

script needed

Posted on 2014-01-17
8
232 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 18

Expert Comment

by:Steven Harris
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:williamstechnologygroup
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I ended up using Robocopy in multiple bat files to accomplish the task.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

I had a question today where the user wanted to know how to delete an SSL Certificate, so I thought that I would quickly add this How to! Article for your reference. WHY WOULD YOU WANT TO DELETE A CERTIFICATE? 1. If an incorrect certificate was …
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
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 walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

762 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

9 Experts available now in Live!

Get 1:1 Help Now