Solved

Copy selected backup file to another drive

Posted on 2014-03-05
7
268 Views
Last Modified: 2014-03-09
My backup application outputs a file called servername_YYYY_MM_DD_HH_MM_SS with each backup job run.

I wish to automate copying this file to another drive for offsite storage purposes. Since there will be multiple backup files of this server by date/time what script can I use to select the last, or most recent backup file to copy?
0
Comment
Question by:mcooper13
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Expert Comment

by:Jason Ryberg
ID: 39906525
Here is a PowerShell method to select the latest written file in a directory:

$Path = \\server\backup_directory
Get-ChildItem $Path | sort LastWriteTime | Select -Last 1

Open in new window

0
 

Author Comment

by:mcooper13
ID: 39906756
What would be the best way to schedule PowerShell script to run daily? Task scheduler?
0
 
LVL 4

Expert Comment

by:Jason Ryberg
ID: 39906783
Yes, task scheduler is a good choice.
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 17

Expert Comment

by:Gerald Connolly
ID: 39908654
Just to be pedantic, that script doesnt do what you expect, it is using the last write time (not sure if thats "created date-time" or "modified date-time") from the file metadata, not selecting by filename.
0
 

Author Comment

by:mcooper13
ID: 39909187
To clarify, the drive that stores the daily backup files for server1 will also have backup files for server2, 3, etc. so good point. The file name does need to be part of the selection criteria.
0
 
LVL 4

Accepted Solution

by:
Jason Ryberg earned 350 total points
ID: 39909507
The easiest way to parse through a single directory with all your server backups would be to input a file that contains the list of servers.  Not knowing if you conform to a server naming standard, it would be hard to recommend a looping method to group the server backups by server name.

So, assuming you have a list you can input into PowerShell (CSV, txt, etc):

$servers = Import-CSV C:\pathToservers.csv #With "servers" as the header

$Path = \\server\backup_directory
#$BackupDir = Get-ChildItem $Path

$mostrecentBUs = @()

$servers | % {

  $mostrecentBUs += Get-ChildItem "$Path\$($_.servers)_*" | sort LastWriteTime | Select -Last 1

}

$mostrecentBUs | % { Copy-Item $_.FullName \\destination\address  }

Open in new window


Hopefully this helps.
0
 
LVL 17

Expert Comment

by:Gerald Connolly
ID: 39916806
Doh! and i didnt even get a few points for pointing out that glitch!!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

690 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