Home → Resources → Articles

Robocopy Job Template

(Ektron CMS 400.Net,Microsoft Windows,Microsoft ASP.NET,Web Programming) by Jason Skowronek on 12/31/2010

When not using a full MSBuild deployment, I leverage the Windows Robocopy utility to deploy website files. I have put together a job template for reference and general use.

Usage: robocopy.exe /job:"c:\path_to_job_file\job_file.rcj"

Download the Robocopy Job Template 

Enjoy.

:: Source Directory :
/sd:c:\%SOURCE_PATH%	:: Source Directory.
	
:: Destination Directory :
/dd:c:\%DEST_PATH%	:: Destination Directory.

	
:: File selection options
:: /a		:: Copies only files for which the Archive attribute is set.
:: /m		:: Copies only files for which the Archive attribute is set, and resets the Archive attribute.

	
::  R – Read only
::  A – Archive
::  S – System
::  H – Hidden
::  C – Compressed
::  N – Not content indexed
::  E – Encrypted
::  T – Temporary
::  O - Offline
:: /ia:[RASHCNETO]		:: Includes only files for which any of the specified attributes are set.
:: /xa:[RASHCNETO]		:: Excludes files for which any of the specified attributes are set.

	
/xf <FileName>[ ...]		:: Excludes files that match the specified names or paths. Note that FileName can include wildcard characters (* and ?).
	*.fla
	*.as
	*.cs
	*.vb
	*.csproj
	*.config
	*.user
	*.Publish.xml
	Readme.txt
	EkDAVlog.txt
	noise.enu	

	
/xd	:: Excludes directories that match the specified names and paths.
	.svn
	App_Browsers
	App_Code
	App_GlobalResources
	App_WebReferences
	AssetManagement
	aspnet_client
	Common
	Config
	LatestChanges
	Properties
	Widgets
	Assets
	Logs
	Obj
	Privateassets
	Uploadedfiles
	Uploadedimages
	Workarea

	
:: /xct		:: Excludes changed files.
:: /xn		:: Excludes newer files.
:: /xo		:: Excludes older files.
:: /xx		:: Excludes extra files and directories.
:: /xl		:: Excludes "lonely" files and directories.
:: /is		:: Includes the same files.
:: /it		:: Includes "tweaked" files.
:: /max:<N>		:: Specifies the maximum file size (to exclude files bigger than N bytes).
:: /min:<N>		:: Specifies the minimum file size (to exclude files smaller than N bytes).
:: /maxage:<N>		:: Specifies the maximum file age (to exclude files older than N days or date).
:: /minage:<N>		:: Specifies the minimum file age (exclude files newer than N days or date).
:: /maxlad:<N>		:: Specifies the maximum last access date (excludes files unused since N).
:: /minlad:<N>		:: Specifies the minimum last access date (excludes files used since N) If N is less than 1900, N specifies the number of days. Otherwise, N specifies a date in the format YYYYMMDD.
:: /xj		:: Excludes junction points, which are normally included by default.
:: /fft		:: Assumes FAT file times (two-second precision).
:: /dst		:: Compensates for one-hour DST time differences.
:: /xjd		:: Excludes junction points for directories.
:: /xjf		:: Excludes junction points for files.

	

	
:: Copy options
/s				:: Copies subdirectories. Note that this option excludes empty directories.
/e				:: Copies subdirectories. Note that this option includes empty directories.
:: /lev:<N>	:: Copies only the top N levels of the source directory tree.
:: /z				:: Copies files in Restart mode.
:: /b				:: Copies files in Backup mode.
:: /zb				:: Uses Restart mode. If access is denied, this option uses Backup mode.
:: /efsraw		:: Copies all encrypted files in EFS RAW mode.
:: /copy:<CopyFlags>	:: Specifies the file properties to be copied.
		:: The following are the valid values for this option:
			:: D Data
			:: A Attributes
			:: T Time stamps
			:: S NTFS access control list (ACL)
			:: O Owner information
			:: U Auditing information
		:: The default value for CopyFlags is DAT (data, attributes, and time stamps).

	
:: /dcopy:T	:: Copies directory time stamps.
:: /sec			:: Copies files with security (equivalent to /copy:DAT).
:: /copyall	:: Copies all file information (equivalent to /copy:DATSOU).
:: /nocopy		:: Copies no file information (useful with /purge).
:: /secfix		:: Fixes file security on all files, even skipped ones.
:: /timfix		:: Fixes file times on all files, even skipped ones.
:: /purge		:: Deletes destination files and directories that no longer exist in the source. For additional information, see Remarks.
:: /mir			:: Mirrors a directory tree (equivalent to /e plus /purge). For additional information, see Remarks.
:: /mov			:: Moves files, and deletes them from the source after they are copied.
:: /move			:: Moves files and directories, and deletes them from the source after they are copied.
:: /a+:[RASHCNET]	:: Adds the specified attributes to copied files.
:: /a-:[RASHCNET]	:: Removes the specified attributes from copied files.
:: /create		:: Creates a directory tree and zero-length files only.
:: /fat			:: Creates destination files by using 8.3 character-length FAT file names only.
:: /256			:: Turns off support for very long paths (longer than 256 characters).
:: /mon:<N>	:: Monitors the source, and runs again when more than N changes are detected.
:: /mot:<M>	:: Monitors source, and runs again in M minutes if changes are detected.
:: /rh:hhmm-hhmm		:: Specifies run times when new copies may be started.
:: /pf				:: Checks run times on a per-file (not per-pass) basis.
:: /ipg:n		:: Specifies the inter-packet gap to free bandwidth on slow lines.
:: /sl				:: Copies the symbolic link instead of the target.

	
:: Retry Options :
/r:2	:: number of Retries on failed copies: default 1 million.
/w:10		:: Wait time between retries: default is 30 seconds.


:: Logging Options :
/v		:: produce Verbose output, showing skipped files.

Comments (2)

Nate K

7/27/2011 3:59:23 PM
How do you pass in the source and destination to the job?

Jason

7/27/2011 4:06:50 PM
I'll update this with an example command line. You can also use /? to lookup the available command options for the robocopy application. robocopy /job:"c:\path to job\job.rcj" :: :: Job Options : :: /JOB:jobname :: take parameters from the named JOB file.
Leave a comment
Name *
Email *
Homepage
Comment

Recommend

System Mechanic 

System Mechanic 

SkoNet provides comprehensive digital consulting services such as: web development, applications development, database design and architecture, business process management, customer relationship management, and many others that help businesses of every size, industry, and geography meet the complex challenge of managing and sharing information on the web. Our skills and expertise in online systems allow us to help customers build applications ranging from simple, single-page web sites to robust enterprise systems.

Online Backup, Ektron Consulting, Ektron Programmer, Ektron Developer, Ektron Partner Utah, Ektron Partner, Ektron Architect, Ektron Hosting, Salesforce.com Consultant Utah, Salesforce.com Partner Utah, Salesforce.com Partner, Salesforce.com Programmer, Salesforce.com Architect, Salesforce.com APEX Programmer