xcopy how to Copy local files to a remote server

Source: Internet
Author: User
Tags exit command line file copy mongodb naming convention postgresql redis


xcopy how to Copy local files to a remote server



1.net use IP address password/user:******



2.xcopy File IP Address



The batch file is backup.bat with the following code:



=========================================================================================



NET use 192.168.1.198ipc$ Zqf198703/user:royalpeak



xcopy G:backup*.* 192.168.1.198 Data backup/d/e/y/h/k



NET use 192.168.1.198ipc$/delete



You can do it with the Xcopy command.



xcopy Source Path target path



Copy files and directories, including subdirectories.



Grammar



xcopy Source [destination] [/w] [/P] [/C] [/v] [//////////////////////[///////////////////////L] h] [{/a|/m}] [/n] [o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z]



Parameters



Source



Required. Specifies the location and name of the file to be copied. The parameter must contain a drive or path.



Destination



Specifies the target of the file to be copied. This parameter can contain a drive letter and a colon, a directory name, a file name, or a combination of them.



/w



The following message is displayed and waits for your response before you begin copying files:



Press any key to begin copying file (s)



/P



Prompts you to confirm whether you want to create each destination file.



/C



Ignore the error.



/V



Validate each file when writing to the destination file to ensure that the destination file is exactly the same as the source file.



/q



Suppresses the display of XCOPY messages.



/F



Displays the source and destination file names when copying.



/L



Displays a list of files to copy.



/g



Creates a decrypted destination file.



/D[:MM-DD-YYYY]



Copies only those source files that have been changed after a specified date or a specified date. If you do not include the MM-DD-YYYY value, xcopy copies all new Source files that are newer than the existing destination file. This command-line option allows you to update files that have changed.



/u



Copy only the files that are already in the destination from source.



/I



If Source is a directory or contains wildcard characters, and destination does not exist, Xcopy assumes that destination specifies the directory name and creates a new directory. Xcopy then copies all the specified files to the new directory. By default, Xcopy prompts you to specify whether destination is a file or a directory.



/s



Copies non-empty directories and subdirectories. If omitted, the/s,xcopy will work in a directory.



/e



Copy all subdirectories, including empty directories. Use the/e,/s, and/T command-line options at the same time.



/t



Copy only the subdirectory structure (that is, the directory tree) and do not copy the files. To copy an empty directory, you must include the/e command-line option.



/k



Copies the file and retains the property in the destination file if the source file has a read-only property. By default, Xcopy deletes read-only properties.



/R



Copy a read-only file.



/h



Copy files that have hidden and system file attributes. By default, Xcopy does not replicate hidden or system files.



/A



Copy only the source files that have the archive file property settings. /A does not modify the archive file properties of the source file. For information about how to set archive file properties by using attrib, see Related Topics.



/m



Copy the source file with the Archive file property settings. Unlike/A,/m closes the archive file attribute of the file specified in the source. For information about how to set archive file properties by using attrib, see Related Topics.



/n



Create a copy using an NTFS short file or directory name. You need/n when you copy a file or directory from an NTFS volume to a FAT volume or when the destination file system requires a FAT file system naming convention (that is, 8.3 characters). The destination file system can be fat or NTFS.



/O



Copy file ownership and discretionary access control List (DACL) information.



/x



Copy file auditing settings and system access control List (SACL) information (including/O).



/exclude:filename1[+[filename2]][+[filename3]]



Specifies a list of files that contain strings.



/y



Suppresses prompting you to confirm that you want to overwrite an existing destination file.



/-y



Prompts you to confirm that you want to overwrite an existing destination file.



/z



Replicated over the network in restartable mode.



/?



Display Help at the command prompt.



Comments



Use/V



Windows XP does not use this command. Use it only to be compatible with MS-DOS files.



Using/exclude



Lists each string in a separate row for each file. If any of the strings listed match any part of the absolute path of the file to be copied, the file is excluded from the replication process. For example, if you specify the string "obj", all files under the OBJ directory are excluded. If the string ". obj" is specified, all files with the. obj extension are excluded.



Using/z



If a connection is lost during replication (for example, if the server used for the connection is offline), the replication process is restored after the connection is reconnected. /z also displays the percentage of replication operations completed per file.



using/y in Copycmd environment variables



You can use/y in copycmd environment variables. Use/-y on the command line to override the command. By default, you are prompted to overwrite unless you run copy from within a batch script.



Copy an encrypted file



Copying an encrypted file to a volume that does not support EFS can result in an error. You should first decrypt the file or copy the file to a volume that supports EFS.



Ancillary files



To attach a file, specify a single destination file, multiple source files (using wildcard characters or file 1 + file 2 + file 3 format).



Default value for Destination



If you omit the destination,xcopy command, copy the file to the current directory.



Specify whether destination is a file or a directory



If destination does not contain an existing directory and does not end with a backslash (), the following message appears:



Does destination specify a file name



or directory name on the target



(F = file, D = directory)?



If you want to copy one or more files to a file, press F. If you want to copy one or more files to a directory, press D.



Using the/I command-line option suppresses the display of this message, which causes Xcopy to determine that the destination is a directory when the source is multiple files or a directory.



To set the Archive property of a destination file using the xcopy command



The xcopy command creates a file with an archive property setting, regardless of whether this property is set in the source file. For more information about file properties and attrib, see Related Topics.



Compare Xcopy and diskcopy



If your disk's subdirectories contain files, and you want to copy them to a disk that has a different format, use the xcopy command instead of diskcopy. Because the diskcopy command is a track to copy a disk, you need the same format for the source and destination disks. The xcopy command does not have this requirement. You typically use xcopy unless you need a full copy of the disk image.



Xcopy's exit code



To handle the exit code returned by Xcopy, use the errorlevel parameter on the IF command line of the batch program. For an example of a batch program that uses "if" to handle exit codes, see Related Topics. The following table lists each exit code and description.



Exit code Description



0 file copy no errors.



1 No files were found to copy.



2 users terminated xcopy by pressing CTRL + C.



4 An initialization error occurred. There is not enough memory or disk space, or an invalid drive name or syntax was entered on the command line.



5 A disk write error has occurred


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.