svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

svn 文件副本已锁定

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

When trying to create simple file copy backups in Windows, a common problem is locked files which can trip up the operation. Whether the file is currently opened by the user or locked by the OS itself, certain files have to be completely unused in order to be copied. Thankfully, there is a simple solution: Shadow Copies.

尝试在Windows中创建简单的文件副本备份时,常见的问题是锁定的文件可能会使操作中断。 无论文件是当前由用户打开还是由OS本身锁定,某些文件都必须完全未使用才能进行复制。 幸运的是,有一个简单的解决方案:卷影副本。

Using our simple tool, you can easily access shadow copies which allows access to point-in-time copies of the currently locked files as created by Windows Restore.

使用我们的简单工具,您可以轻松访问卷影副本,从而可以访问由Windows Restore创建的当前锁定文件的时间点副本。

Image credit: Best Backup Services

图片来源: 最佳备份服务

什么是卷影副本? (What Are Shadow Copies?)

Shadow copies are a concept which was first introduced in Windows Server 2003. It works by Windows periodically crawling the system and looking for file changes made since the last crawl and recording the changes. These changes are indexed and stacked on top of each other which creates a history of the file/folder. This process was then added to the Windows Vista OS under the System Restore function which is where it remains today. The technology is the foundation of the Windows previous versions functionality.

卷影副本是Windows Server 2003中首次引入的概念。Windows会定期对系统进行爬网,并寻找自上次爬网以来所做的文件更改并记录更改。 这些更改被索引并堆叠在一起,从而创建文件/文件夹的历史记录。 然后,此过程已添加到Windows Vista OS的“系统还原”功能下,该功能至今仍保留。 该技术是Windows早期版本功能的基础。

This is done in the background as a system level process (a Restore Point creation) which isn’t subject to the same limitations as user initiated file operations. As a result, the system is able to capture changes to files which are locked to the user.

这是作为系统级过程(创建还原点)在后台完成的,与用户启动的文件操作没有相同的限制。 结果,系统能够捕获对用户锁定的文件的更改。

So in order to access a locked file, we simply need to access the latest shadow copy. This is the same premise used by Windows Backup and other commercial backup products which are able to access, for example, Outlook PST files while Outlook remains open.

因此,为了访问锁定的文件,我们只需要访问最新的卷影副本。 这与Windows Backup和其他商业备份产品使用的前提相同,这些产品可以在Outlook保持打开状态时访问例如Outlook PST文件。

It is important to note, however, that since shadow copies are taken when a system restore point is created, the contents between the live file and shadow copy version can be different. By default, Windows creates a restore point every day so for most situations this should be a reasonable candidate for backup.

但是,请务必注意,由于在创建系统还原点时会进行卷影副本,因此活动文件和卷影副本版本之间的内容可能会有所不同。 默认情况下, Windows每天都会创建一个还原点,因此在大多数情况下,它应该是进行备份的合理选择。

访问卷影副本 (Accessing Shadow Copies)

From this point, the article assumes you are using our tool provided via the link at the bottom of the article. The batch script should be placed in a folder set in your Windows PATH variable. If you are unsure, just place it in your C:\Windows directory and that should be good enough.

从这一点来看,本文假设您正在使用通过文章底部链接提供的我们的工具。 批处理脚本应放在Windows PATH变量中设置的文件夹中。 如果不确定,只需将其放在C:\ Windows目录中就足够了。

In order to access the files saved within shadow copies, we utilize the VSSAdmin command line tool which is included with Windows. This tool must be run as the administrator in order to function properly so when you open a command prompt, be sure to right-click and select the option to ‘Run as Administrator’.

为了访问卷影副本中保存的文件,我们利用Windows附带的VSSAdmin命令行工具。 此工具必须以管理员身份运行才能正常运行,因此当您打开命令提示符时,请确保右键单击并选择“以管理员身份运行”选项。

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

Once open, our tool does the heavy lifting for you. To view the syntax and header information for the tool, just enter:

打开后,我们的工具将为您完成繁重的工作。 要查看该工具的语法和标题信息,只需输入:

MountLatestShadowCopy /?

MountLatestShadowCopy /?

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

As an example, the command:

例如,命令:

MountLatestShadowCopy C:\LatestShadow\ C:

MountLatestShadowCopy C:\ LatestShadow \ C:

will perform the following actions:

将执行以下操作:

  1. Locate the latest shadow copy for drive C.

    找到驱动器C的最新卷影副本。
  2. Create a symbolic link/pseudo-directory “C:\LatestShadow”

    创建一个符号链接/伪目录“ C:\ LatestShadow”
  3. Make the entire contents of the shadow copy available at this directory.

    使卷影副本的所有内容在此目录中可用。

Once complete, you are free browse the contents either through the command prompt:

完成后,您可以通过命令提示符*浏览内容:

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

or through Windows Explorer, just like any other folder.

或通过Windows资源管理器,就像其他任何文件夹一样。

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

When you are finished, you can simply delete the pseudo-directory through the command prompt using:

完成后,您可以使用以下命令通过命令提示符简单地删除伪目录:

RMDIR C:\LatestShadow

RMDIR C:\ LatestShadow

or directly through Windows Explorer. The delete action simply unmounts the folder and does not actually delete the shadow copy.

或直接通过Windows资源管理器。 delete操作只是卸载该文件夹,而实际上并不删除卷影副本。

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

在脚本/自动任务中使用 (Using in Scripts / Automated Tasks)

The information above is all fine and dandy, but through manual operation it is more relevantly accessible via Windows previous versions. The leverage our tool provides is during automated processes.

上面的信息都很好,但通过手动操作,可以通过Windows以前的版本更相关地访问。 我们的工具在自动化流程中提供了杠杆作用。

For example, the script below will mount the latest shadow copy to the local directory “C:\MyShadow” and then copy the “outlook.pst” located in user JDoe’s documents folder to a backup server. Once finished, the local directory which held the shadow copy location is removed to clean itself up.

例如,下面的脚本会将最新的卷影副本安装到本地目录“ C:\ MyShadow”,然后将用户JDoe的documents文件夹中的“ outlook.pst”复制到备份服务器。 完成后,将删除拥有卷影副本位置的本地目录以进行自我清理。

CALL MountLatestShadowCopy C:\MyShadow\

呼叫MountLatestShadowCopy C:\ MyShadow \

XCOPY “C:\MyShadow\Users\JDoe\Documents\Outlook\outlook.pst” “\\BackupServer\MyFiles\”

XCOPY“ C:\ MyShadow \ Users \ JDoe \ Documents \ Outlook \ outlook.pst”“ \\ BackupServer \ MyFiles \”

RMDIR C:\MyShadow

RMDIR C:\ MyShadow

If you tried to copy the live version of the same file and the user had it open at the time, your file copy operation would fail. However, since we accessed the file via a shadow copy, there are no locks and the copy procedure virtually always succeeds. As stated previously, this procedure is pretty much exactly how popular backup products are able to do the same thing.

如果您尝试复制同一文件的实时版本,并且用户当时打开了该版本,则文件复制操作将失败。 但是,由于我们是通过卷影副本访问文件的,因此没有锁,并且复制过程实际上总是成功的。 如前所述,此过程几乎与流行的备份产品能够执行相同操作的方式完全相同。

An important piece of information noted above is that in order to run the above script, or any script which uses the MountLatestShadowCopy.bat tool (which, again makes use of the VSSAdmin tool), the command prompt must be run as the administrator account. In order to use this tool inside of a scheduled task, the respective task must be set to ‘Run with highest privileges’ so that the automated process will have the ability to mount shadow copies using the VSSAdmin tool.

上面提到的一条重要信息是,为了运行上述脚本或任何使用MountLatestShadowCopy.bat工具(再次使用VSSAdmin工具)的脚本,必须以管理员帐户运行命令提示符。 为了在计划的任务中使用此工具,必须将各个任务设置为“以最高特权运行”,以便自动化过程能够使用VSSAdmin工具安装卷影副本。

svn 文件副本已锁定_什么是“卷影副本”?如何使用它们复制锁定的文件?

In a nutshell, performing file copy backups is almost always the safest when copying from shadow copies. While you will not always get the most up to date version of a file, the fact that you know the file will not be locked and the copy procedure will run can be quite advantageous under most circumstances.

简而言之,从卷影副本进行复制时,执行文件副本备份几乎总是最安全的。 尽管您不一定总能获得文件的最新版本,但在大多数情况下,您知道文件将不会被锁定且复制过程将运行的事实可能会非常有利。

Download MountLatestShadowCopy tool from HowToGeek.com

从HowToGeek.com 下载MountLatestShadowCopy工具

翻译自: https://www.howtogeek.com/129188/htg-explains-what-are-shadow-copies-and-how-can-i-use-them-to-copy-or-backup-locked-files/

svn 文件副本已锁定