*! version 1.3 20 Dec 2013

help for backupAndres Castaneda

Back up files and folders

backup -- Program to automatically create backup of any type of file

Syntax

backup
[,
options]

Sections

Help is presented under the following headings:

Description
Options
Examples

Main
source(string) Source Directory (local or network path)

destination(string) Destination Directory (local or network path)

mirror Mirror a directory tree with all the sub-folders including empty directories

copy(string) Specifies the file properties to be copied

Files(string) list of files to copy

start(string) Folder from the source directory from which the folder tree is desired to start

nfolders(int 8) Number of folders with backup of the same directory

period(string) Frequency for copying each folder

speed(int 32) Number of files copied in parallel

xdir(string) Directories to be excluded from being copied

xfile(string) Type of files to be excluded from being copied

infile(string) Type of files to be copied

Description

backup Copies any type of file maintaining the permissions, attributes, owner information, timestamps
and properties of the objects copied. It uses the DOS command-line ROBOCOPY to perform the backup,
so it only works over Windows for now.
backup is very useful as one of the instructions of the profile.do in which you
can set which files or folders are desired to be backed up each time Stata is started. In addition, backup might
be used at the beginning or ending of any do-file in order to ensure a backup of all the files developed
in a project.

Back to Sections

Options

Main

source(string) Source Directory (local or network path).

destination(string) Destination Directory (local or network path)

NOTE: If either the source or desination are a "quoted long foldername" do not include a trailing
backslash as this will be treated as an escape character, i.e. "C:\some path\" will fail but
"C:\some path\\" or "C:\some path\." or "C:\some path" will work

files(string) Name of file to act upon. File you want to copy o type of file you need to copy.
You can use wildcard characters (? and *). If no files are listed, backup defaults to all files (*.*)

mirror mirror a directory tree with all the subfolders including the empty directories and you
purge files and folders on the destination server that no longer exists in source.

copy(string) Specifies the file properties to be copied. The following are the valid values
for this option:

Value ... Property

D Data
A Attributes
T Time stamps
S NTFS access control list (ACL)
O Owner information
U Auditing information

The default is DAT. Do not specify values separated with spaces.

start(string) from the source path, select directory from which you want to preserve the tree
structure of the original folder

nfolders(int 8) Number of folder you want to keep in you backup directory. In other words, you can
specify how many copies of your backup by date you want to have. Default is 8 folders

period(string) you can select how many days, weeks, month, quarters or years will be the frequency
of your backup. If you specify just a number, backup will understand it as number of days.
the period has the following syntax. x[d|w|m|q|s|y] where x is any number and d refers to days;
w to weeks; m to 30-day months; q to 90-day quarters; s to 180-day semester; and
y to 360-day years.

period ... is equivalent to typing

9 Nine-days backup frequency
4d Four-days backup frequency
3w three-weeks (21 days) backup frequency
3m three-months backup frequency
1q one-quarter (90 day) backup frequency
1y one-year backup frequency

speed(int 32) Multi-threaded support allows backup using Windows command-line
Robocopy to open multiple threads simultaneously,
allowing many files to be copied in parallel. With multi-threaded copying, total time required to
complete the operation will be drastically reduced and cut, when comparing with with typical copying
one file at time in serial sequential order. the value of speed must be at least 1 and not greater
than 128. Default is 32.

xdir(string) Directories to exclude from the directory source. If one of the folders within the
directory path has intermediate blanks it is important to use double compounded quotes (`""') and
separate each directory with double quotes ("")

xfile(string) File/s or type/s of file to exclude. Not use with option infile

infile(string) File/s or type/s of file to include. Not use with option xfile

Back to Sections

Examples

Basic

Copy everything from "C:\source" to "E:\destination" excluding the folder "C:\source\exclude"
and "C:\source\to exclude". Multi-thread set to 100, maximum six copies of "C:\source" will be kept in
"E:\destination" organized by dates. Copies will be performed every other week (2w)

backup, source("C:\source") destination("E:\destination") ///
xdir(`" "C:\source\exclude" "C:\source\to exclude" "') ///
speed(100) nfolders(6) period(2w) mirror

Files

Copy everything from "C:\source\a\b\c" to "E:\destination" starting folder tree from "C:\source\a\b".
Multi-thread set to 100, maximum six copies of "C:\source\a\b\c" will be kept in
"E:\destination" organized by dates. Copies will be performed every three days (2w). Only files Excel
files that start with the word "graphs" and do-files that start with the word "programs" will be copied.

backup, source("C:\source\a\b\c") destination("E:\destination") ///
start(b) files(graphs*.xlsx programs*.do) ///
speed(100) nfolders(6) period(3d) mirror

Back to Sections

Additional information

Website ROBOCOPY, Microsoft

Author

Andrés Castañeda, The World bank.
Email acastanedaa@worldbank.org