?
Solved

Getting started with Robocopy

Posted on 2012-03-25
6
Medium Priority
?
587 Views
Last Modified: 2014-11-12
a friend recomended robocopy, i wish to get started, but have no idea how.

i am using server 2008 r2
i want to copy a folder called c:\gdrive  to my f drive
i woul dlike robocopy to make a new folder on my f drive, rather then over write it.
my ideal situation would be to have a new folder corresponding to the day of the month the copies were made.
it is fine with me, if it makes one copy, then subsequent are only the changed files... but i do  have a small amount of data and a large destination drive.

is anyone familiar....with how i would begin.?
0
Comment
Question by:intelogent
[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
6 Comments
 
LVL 2

Expert Comment

by:ven16
ID: 37762572
may the below link helps you to do it, it use the powershell script.
and let me know the result
http://itnshare.blogspot.co.uk/2009/10/autorotate-and-renaming-files-as-for_14.html
0
 
LVL 30

Expert Comment

by:IanTh
ID: 37762586
best link for robocopy is
http://ss64.com/nt/robocopy.html

it has all th command options
0
 
LVL 6

Expert Comment

by:Tomislavj
ID: 37762590
maybe free cobian backup 8 is easier to use for this purpose because there's no need for scripts, just choose options (and there is option for have daily backups as different names)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Brent Challis
ID: 37769618
I have a PowerShell function that I use for backing up files.  It creates a command line for running RoboCopy after reading a configuration file which is a csv file listing the sourcedirectory,targetdirectory


# ==============================================================================================
#
# NAME: Backup-RCopy
#             PowerShell utility which utilises RoboCopy to perform the copying of the directory
#            structure copying the files that are new or altered.
# AUTHOR: bchallis ,
# DATE  : 26/01/2012
#
# COMMENT:
#
# ==============================================================================================
function Backup-RCopy
{
    [CmdletBinding(SupportsShouldProcess=$True)]
    Param
    (
        [Parameter(Mandatory=$True)]
        [string]$ConfigurationFileName,
        [Parameter(Mandatory=$True)]
        [string]$LogFileName,
        [switch]$Force
    )

    function Log
    {
        Param
        (
            [parameter(Mandatory=$true)]
            [int]$Level,
            [parameter(Mandatory=$true)]
            [String]$TaskCategory,
            [parameter(Mandatory=$true)]
            [String]$Message
        )
        if (Test-Path Function:\Add-BCLogEntry)
        {
            Add-BCLogEntry -Path $LogFileName -Level $Level -Source "BackupRCopy" -taskCategory $TaskCategory -message $Message
        }
          else
        {
              ("[{0}] {1}" -f ([System.DateTime].Now.ToString()),$Message) | Out-File -FilePath $LogFileName -Append
        }
    }
   
    function IsNull
    {
          Param
          (
                $value,
                $default
          )
          $retValue = $value
          if ($value -eq $null)
          {
                $retValue = $default
          }
          else
          {
                if ([String].IsNullOrEmpty($value))
                {
                      $retValue = $default
                }
          }
          return $retValue
    }
   
    function Display-Configuration
    {
          $configurations = Import-Csv $ConfigurationFileName
            foreach ($config in $configurations)
            {
            $sourceDirectory = $config.SourceDirectory.Trim()
            if (-not $sourceDirectory.EndsWith("\"))
            {
                $sourceDirectory += "\"
            }
            $targetDirectory = $config.DestinationDirectory.Trim()
            if (-not $targetDirectory.EndsWith("\"))
            {
                $targetDirectory += "\"
            }
            Write-Host      "Source directory = $sourceDirectory - Target directory = $targetDirectory."
            }
    }

#############################################################################################################
# Main Code
#############################################################################################################

      $errorsFound = $false
      if (Test-Path $ConfigurationFileName)
      {
          Write-Verbose "Using configuration file $ConfigurationFileName"
            $configurations = Import-Csv $ConfigurationFileName
            foreach ($config in $configurations)
            {
                  if ($config -ne $null)
                  {
                        $sourceDirectory = $config.SourceDirectory
                        $targetDirectory = $config.DestinationDirectory
                        if (($sourceDirectory -ne $null) -and ($targetDirectory -ne $null))
                        {
                              if ($PSCmdlet.ShouldProcess((Get-Item env:\ComputerName).Value, ("Backing up {0} up to {1}" -f $sourceDirectory,$targetDirectory)))
                              {
                              if (-not $sourceDirectory.EndsWith("\"))
                              {
                                  $sourceDirectory += "\"
                              }
                              if (-not $targetDirectory.EndsWith("\"))
                              {
                                  $targetDirectory += "\"
                              }
                              
                              if (-not (Test-Path $targetDirectory))
                              {
                                  if ((Test-Path (Split-Path $targetDirectory -Qualifier)) -and $Force)
                                  {
                                      New-Item $targetDirectory -type directory
                                  }
                              }
                              
                                    if ((Test-Path $sourceDirectory) -and (Test-Path $targetDirectory))
                                    {
                                  $command = "RoboCopy " + $sourceDirectory + " " + $targetDirectory + " /E /Z /XO /COPY:DAT"
                                  
                                      try
                                      {
                                          Write-Verbose "Command: $command"
                                                    $procres = Invoke-Expression $command
                                          if ($verbosePreference)
                                          {
                                              foreach ($o in $procres)
                                              {
                                                  Write-Host $o.ToString()
                                              }
                                          }
                                      }
                                      Catch
                                      {
                                          $errorsFound =$true
                                      }
                                    }
                                    else
                                    {
                                  $message = ("Unable to locate source ($sourceDirectory) and destination ($targetDirectory) directories.")
                                  Log -Message $message -Level 2 -TaskCategor y "Backing up files"
                                  $errorsFound =$true
                                          Write-Warning $message
                                    }
                              }
                              else
                              {
                                    # Selected to not perform action
                              }
                        }
                  }
            }
                Add-BCLogEntry -Path $LogFileName -Level 0 -Source "rBackup" -TaskCategory "SuccessfulBackup" -Message "Backup Complete"
      }
      else
      {
            $errorsFound =$true
            Log -Level 3 -TaskCategory "Initialisation" -Message "configuration File not found."
            Write-Warning "Unable to find configuration file $ConfiguratinFileName"
      }
}
0
 
LVL 8

Expert Comment

by:SeaSenor
ID: 37777088
Intelogent... here is the .bat file I think you were wanting from me.

it is attached
Here are the steps:

1. rename the extension from .txt to .bat

2. I have the source name as:    C:\gdrive
3. I have the destination name as :   F:\gdrive

4. create your 'folderlist' to include the folders you want to copy.  Name it:  folderlist.txt  and place it in the same diretory you put this .bat file ( i use just the C:\  folder)
5. Create a folder named Robocopylogfiles on the F:\   drive.

This script will create a folder with the current date, and copy any new/changed files only.
The first round it will probably copy everything... which is good.

It will also create a log file and it will then put a copy of that days log file into the folder of the day it was created.

This should accomplish what you are asking in your post.

Let me know if you need more help.
Daily-incremental.txt
0
 
LVL 8

Accepted Solution

by:
SeaSenor earned 2000 total points
ID: 37814914
Did that provide what you needed?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

650 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