The postings on this site are my own and do not represent my Employer's positions, advice or strategies.

LifeAsBob

  Wednesday, September 19, 2018

 


Home
Blog
bob tech
Calendar
Contact Bob
Pictures
VW Buses
HomeBrew
Cook Book

 

July 4th 2007

  bob Links
Backing up and resto...
This beer is good for you. This is draft beer. Stick with the beer. Let's go and beat this guy up and come back and drink some more beer. - Ernest Hemingway, To Have and Have Not
Wider View Insert

Cluster
DOS
     Get Directory Path o...
     XCOPY Commands
IBM - AS400
MOM
Performance Counters
Service Broker
SQL Server
Windows OS

Insert Category

Will be added as a sub-category of, DOS
XCOPY Commands
Syntax
      XCOPY source [destination] [options]
Key source : Pathname for the file(s) to be copied. destination : Pathname for the new file(s).

[options] can be any combination of the following:

Source Options
/A Copy files with the archive attribute set (default=Y)
/M Copy files with the archive attribute set and
turn off the archive attribute, use this option
when making regular Backups (default=Y)

/H Copy hidden and system files and folders (default=N)
/D:mm-dd-yyyy
Copy files that have changed since mm-dd-yyyy. If no date is given, the default is to copy
files with a modification date before today. (at least 1 day before)
/U Copy only files that already exist in destination.
/S Copy folders and subfolders
/E Copy folders and subfolders, including Empty folders.
May be used to modify /T. /EXCLUDE:file1[+file2][+file3]... (Windows 2000 only) The files can each contain one or more full or partial pathnames to be excluded. When any of these match any part of the absolute path of a SOURCE file, then that file will be excluded. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.

Copy Options

/W Prompt you to press a key before starting to copy.
/P Prompt before creating each file. /Y (Windows 2000 only) Suppress prompt to confirm overwriting a file. may be preset in the COPYCMD env variable. /-Y (Windows 2000 only) Prompt to confirm overwriting a file.

/V
Verify that the new files were written correctly. /C Continue copying even if an error occurs.
/I If in doubt always assume the destination is a folder
e.g. when the destination does not exist.

/Z Copy files in restartable mode. If the copy is interrupted part
way through, it will restart if possible. (use on slow networks)
/Q Do not display file names while copying. /F Display full source and destination file names while copying. /L List only - Display files that would be copied.
Destination Options
/R Overwrite read-only files.
/T Create folder structure, but do not copy files. Do not include empty folders or subfolders.
/T /E will include empty folders and subfolders.
/K Copy attributes. XCOPY will otherwise reset read-only attributes.

/N If at all possible, use only a short filename (8.3) when creating a destination file. This may be nececcary when copying between disks that are formatted differently e.g NTFS and VFAT, or when archiving data to an ISO9660 CDROM. /O (Windows 2000 only) copy file Ownership and ACL information. /X Copy file audit settings (implies /O).

XCOPY will accept UNC pathnames

Examples:

To copy a directory tree with no files, includes sub-folders, even empty ones

XCOPY u:\SourceDir\*.* u:\TargetDir /s /i /T /E

To copy a file:

XCOPY C:\utils\MyFile D:\Backup\CopyFile

To copy a folder:

XCOPY C:\utils D:\Backup\utils /i

To copy a folder including all subfolders.

XCOPY C:\utils\* D:\Backup\utils /s /i

The /i defines the destination as a folder.

 

Exclude files:

XCOPY C:\DATA\*.* C:\BKUP /S /I /Y /EXCLUDE:c:\excludelist.txt

the /S flag = copies all directories and subdirectories except empty ones (use the /E instead if you want empty folders also copied)

the /I flag = If the destination does not exist and we are copying more than one file, it will assume the destination is a folder

the /Y flag = Suppresses all prompts to overwrite destination file if it already exists

the /EXCLUDE flag = this will point to a file that has the excluded file types or folder or file names. in my example, i created a text file called: excludelist.txt in the root of my C: drive.

in that excludelist.txt, i then added the word SECRET on the first line. If you have more than one excluded item; be sure to put each on a new line.

The main thing to remember when using the /EXCLUDE flag is that you have to put the location of the excluded file list after the flag; not the actual excluded items/terms. That initially was the most confusing part. You can create multiple excluded file lists; you would need to use the + list (ie XCOPY c:\* v:\ /EXCLUDE:c:\excluded1.txt+c:\excluded2.txt )