如何在Windows中使用Xcopy复制文件和备份?

作者:神秘网友 发布时间:2020-10-15 20:55:37

如何在Windows中使用Xcopy复制文件和备份?

如何在Windows中使用Xcopy复制文件和备份?

Windows provides very featureful command which is used to copy files can take backups named xcopy . Xcopy can be used copy files from one partition to other partition or a usb drive. Xcopy also supports  incremental backup which create advantages  while taking backups. We will look different usage examples of xcopy in this tutorial.

Windows提供了非常有用的命令,该命令用于复制文件,可以进行名为xcopy备份。 可以使用Xcopy将文件从一个分区复制到另一分区或USB驱动器。 Xcopy还支持增量备份,这在进行备份时具有优势。 在本教程中,我们将查看xcopy的不同用法示例。

帮帮我 (Help)

Detailed help about xcopy command can be show with /? option like below.

可以使用/?显示有关xcopy命令的详细帮助/? 如下所示的选项。

$ xcopy /?
如何在Windows中使用Xcopy复制文件和备份?
Help
帮帮我

复制档案(Copy Files)

One of the most used type of xcopy is  providing no option and just copying files from source path to the destination file. In this example we will provide source file named systeminfo.txt to the Downloads directory.

xcopy最常用的一种类型是不提供任何选项,而只是将文件从源路径复制到目标文件。 在此示例中,我们将向Downloads目录提供名为systeminfo.txt源文件。

$ xcopy systeminfo.txt Downloads
如何在Windows中使用Xcopy复制文件和备份?
Copy Files
复制文件

忽略错误(Ignore Errors)

While copying files there may some errors related permission, corrupt data, changed data etc. These will create errors and these error will be printed to the terminal by default and these errors can be interrupt the copy operation. These errors can be ignored with /c option.

在复制文件时,可能会出现一些与权限有关的错误,数据损坏,数据更改等。这些都会创建错误,并且默认情况下会将这些错误打印到终端,并且这些错误可能会中断复制操作。 使用/c选项可以忽略这些错误。

$ xcopy /c systeminfo.txt Downloads

使用日期和时间戳备份数据 (Backup Data Using Date and Time Stamp)

One of the very useful feature is copying files according to their date and time stamp. While we are making backups regularly we can specify time which files those are changed specified time to backup. For example we take backup in following periodic dates.

非常有用的功能之一是根据文件的日期和时间戳复制文件。 当我们定期进行备份时,我们可以指定更改文件的时间和指定的备份时间。 例如,我们在以下定期日期进行备份。

  • 01-04-2017

    2017年1月4日
  • 08-04-2017

    2017年08月04日
  • 15-04-2017

    15-04-2017

We can specify date where we will only copy files changed after that time. In this example only files those changed after 15-04-2017 will be copied.

我们可以指定仅复制该时间之后更改的文件的日期。 在此示例中,仅复制在15-04-2017之后更改的文件。

$ xcopy \project \project-backup /d:15-04-2017

详细操作 (Verbose Operation)

Other useful feature is printing files during copy operation. This will give us feedback about the copy operation. We will use /f option for this.

其他有用的功能是在复制操作期间打印文件。 这将为我们提供有关复制操作的反馈。 我们将使用/f选项。

$ xcopy /f Downloads Downloads-backup
如何在Windows中使用Xcopy复制文件和备份?
Verbose Operation
详细操作

仅复制现有目标文件(Copy Only Files Existing Destination)

While copying files from source to the destination we can set a rule which will only copy the files existing in remote destination.

在将文件从源复制到目标时,我们可以设置一条规则,该规则将仅复制远程目标中存在的文件。

$ xcopy /u Downloads Downloads-backup

复制隐藏文件和系统文件 (Copy Hidden and System Files)

Windows have different type of files attributed like System and Hidden . These files especially used by operating system or related applications. These files are not copied by default. In order to copy these type of files we will provide /h

Windows具有不同类型的文件,例如SystemHidden 。 这些文件特别由操作系统或相关应用程序使用。 默认情况下,不会复制这些文件。 为了复制这些类型的文件,我们将提供/h

$ xcopy /h Downloads Downloads-backup

排除文件和扩展名进行复制 ( Exclude Files and Extension For Copy)

While copying we may need to not copy some file names or extensions. For example a developer do not want to copy binary or temporary files. So we need to exclude these type of files and file names. We will create a file which stores file names and extensions line by line those will be excluded. We have a file ex.txt which have following contents.

复制时,我们可能不需要复制某些文件名或扩展名。 例如,开发人员不想复制二进制或临时文件。 因此,我们需要排除这些类型的文件和文件名。 我们将创建一个文件,逐行存储将被排除的文件名和扩展名。 我们有一个文件ex.txt ,其中包含以下内容。

.exe
temp

We want to exclude .exe and temp file names and extensions

我们要排除.exetemp文件的名称和扩展名

$ xcopy /exclude:ex.txt Downloads Downloads-backup
LEARN MORE  Set Time Zone With Tzutil In Windows From Command Line 了解更多信息在Windows中通过命令行在Tzutil中设置时区

翻译自: https://www.poftut.com/copy-files-backup-xcopy-windows/

如何在Windows中使用Xcopy复制文件和备份?相关教程

  1. mysql命令行导入导出_如何在Windows中通过命令行添加,删除,删

    mysql命令行导入导出_如何在Windows中通过命令行添加,删除,删除,导入,导出,管理注册表项?... mysql命令行导入导出 Registry is a database used by Windows operating systems to store information about applications, users, operating system, netw

  2. 使用Windows At Command计划作业和任务

    使用Windows At Command计划作业和任务 Linux have the same command for same reasons to schedule commands and jobs for specified times and periods. Windows have the same command with similar usage too. Alternative to this command is schtasks c

  3. 如何使用Netsh命令从命令行管理Windows防火墙?

    如何使用Netsh命令从命令行管理Windows防火墙? Windows firewall is a useful mechanism which is used to control network traffic and ports. There are different ways to manage Windows firewall like GUI, Powershell and MS-DOS. Today we will look

  4. wmic cpu_如何在Windows中使用Wmic命令获取CPU信息?

    wmic cpu_如何在Windows中使用Wmic命令获取CPU信息? wmic cpu Wmic is a set of tools used to get and set operating system related configuration and information. In this tutorial we will look how to get information about CPU. Wmic是用于获取和设

  5. windows读取文件命令_如何在命令行中读取和筛选Windows Update登

    windows读取文件命令_如何在命令行中读取和筛选Windows Update登录 windows读取文件命令 Windows operating systems updates generally done automatically and prompting the installation and restart of the system. All these update operations creates

  6. 如何在Windows NTFS中使用压缩命令在文件系统级别压缩文件和文件

    如何在Windows NTFS中使用压缩命令在文件系统级别压缩文件和文件夹? Windows modern file system NTFS provides some compression mechanisms to gain more space in disks and partitions. This compression operation is done mainly with compact command

  7. 如何在命令行MS-DOS中使用Set命令列出,设置和获取Windows环境变

    如何在命令行MS-DOS中使用Set命令列出,设置和获取Windows环境变量? Operating systems have a lot of configurations. These configurations are stored in different ways in different locations. One of the most common storage for some generic infor

  8. 使用Electron构建运维客户端

    使用Electron构建运维客户端 目录 前言 CMDB Electron Vue Jenkins 获取所有项目 build工程 OpenVPN Rancher 前言 好久没写博客了,疫情期间自闭了。来讲讲最近重新设计的新工具。界面就是这么朴实无华。。类OSX的窗口设计,抄袭QQMac版本的功能栏设计 这个工