linus备份文件命令行_备份/复制Windows中“使用中”或“锁定”的文件(命令行)

linus备份文件命令行

linus备份文件命令行

If you’ve ever tried to copy a file that is locked by another application, you’ve probably seen an error message similar to “The process cannot access the file because another process has locked a portion of the file”. So how do you copy it anyway?

如果曾经尝试复制被另一个应用程序锁定的文件,则可能会看到类似于“该进程无法访问该文件,因为另一个进程已锁定了文件的一部分”的错误消息。 那么,您该如何复制呢?

image

Since XP, Windows has supported a technology called Volume Shadow Copy, which is used to power the previous versions feature in Vista as well as System Restore and backups. What it does is take a temporary snapshot of the file or drive, and then allow an application to read from the snapshot even while other applications are accessing or modifying the file.

从XP开始,Windows支持一种称为卷影复制的技术,该技术用于支持Vista中的先前版本功能以及系统还原和备份。 它的作用是为文件或驱动器创建一个临时快照,然后允许应用程序从快照读取,即使其他应用程序正在访问或修改文件时也是如此。

What we can do is use a command line utility called HoboCopy that utilizes this service to copy the file.

我们可以做的是使用一个名为HoboCopy的命令行实用程序,该实用程序利用此服务来复制文件。

Understanding the Prerequisites

了解先决条件

HoboCopy and most other backup utilities make use of two services in Windows, and you’ll need to verify that these services are not disabled:

HoboCopy和大多数其他备份实用程序在Windows中使用两项服务,因此您需要确认未禁用这些服务:

  • Volume Shadow Copy

    卷影复制
  • Microsoft Software Shadow Copy Provider

    Microsoft软件卷影复制提供程序

They can be left as Manual startup, so they don’t need to be running all the time. Hobocopy will start the two services automatically when needed, and the Volume Shadow Copy service will be turned back off after it’s done.

可以将它们保留为手动启动,因此不必一直运行。 Hobocopy将在需要时自动启动这两个服务,并且卷影复制服务在完成后将被关闭。

Using HoboCopy to Backup/Copy a Single File

使用HoboCopy备份/复制单个文件

The syntax is a little weird, because HoboCopy is really meant to be used for backing up an entire set of folders. We can use it to backup a single file by passing in the filename argument at the end.

语法有点奇怪,因为HoboCopy实际上是用于备份整个文件夹集的。 我们可以通过在末尾传入filename参数来使用它来备份单个文件。

Note: on Windows Vista you will need to launch an Administrator mode command prompt by right-clicking on the Command prompt in the start menu and choosing Run as Administrator.

注意:在Windows Vista上,您需要启动管理员模式命令提示符,方法是在开始菜单中右键单击命令提示符,然后选择以管理员身份运行。

Syntax:

句法:

hobocopy c:\directoryname\ d:\backupdirectory\ <filename>

hobocopy c:\ directoryname \ d:\ backupdirectory \ <文件名>

For example, I want to backup my c:\users\geek\mail\outlook.pst file to d:\backups\outlook.pst. Here’s the syntax that I’d use:

例如,我要将c:\ users \ geek \ mail \ outlook.pst文件备份到d:\ backups \ outlook.pst。 这是我要使用的语法:

C:\> hobocopy c:\users\geek\mail\ d:\backups\ Outlook.pst

C:\> hobocopy c:\用户\怪胎\邮件\ d:\ backups \ Outlook.pst

HoboCopy (c) 2006 Wangdera Corporation. hobocopy@wangdera.com

HoboCopy(c)2006 Wangdera Corporation。 hobocopy@wangdera.com

Starting a full copy from c:\users\geek\mail to d:\backups\Copied directoryBackup successfully completed.Backup started at 2008-03-09 01:57:28, completed at 2008-03-09 01:58:39.1 files (606.45 MB, 1 directories) copied, 7 files skipped

从c:\ users \ geek \ mail开始完整副本到d:\ backups \ Copied目录的备份已成功完成。备份开始于2008-03-09 01:57:28,完成于2008-03-09 01:58:39.1复制文件(606.45 MB,1个目录),跳过7个文件

Using HoboCopy to Backup an Entire Directory

使用HoboCopy备份整个目录

A much more useful task would be to backup my entire User folder, probably to an external hard drive for safekeeping. For this, we’ll want to add a couple of command-line arguments.

一个更有用的任务是将我的整个“用户”文件夹备份,可能备份到外部硬盘驱动器上以进行保管。 为此,我们要添加几个命令行参数。

/fullCopy all files
/skipdeniedIgnore any access denied messages because of permission errors.
/rCopy recursively
/yDon’t prompt, just copy everything
/充分 复制所有文件
/跳过 由于权限错误,请忽略任何拒绝访问的消息。
/ r 递归复制
/ y 不提示,只复制所有内容

Syntax:

句法:

hobocopy /full /skipdenied /y /r c:\directoryname\ d:\backupdirectory\

hobocopy /完整/略过/ y / rc:\目录名\ d:\备份目录\

Let’s go with the same example, I want to backup my entire user directory to d:\backups\, so I’d use this command:

让我们来看同一示例,我要将整个用户目录备份到d:\ backups \,因此我将使用以下命令:

hobocopy /full /skipdenied /y /r c:\users\geek\ d:\backups\

hobocopy /完整/略过/ y / rc:\ users \ geek \ d:\ backups \

This command will likely take a very long time to complete, so you might want to take a nap or something. At the end you should have a nearly perfect copy of the directory… if there are any permission errors you’ll be alerted to files that didn’t copy. Realistically any files in your user directory shouldn’t have this problem.

该命令可能需要很长时间才能完成,因此您可能需要小睡一下。 最后,您应该拥有目录的近乎完美的副本……如果有任何权限错误,您将收到未复制文件的警告。 实际上,用户目录中的任何文件都不应出现此问题。

Using HoboCopy to Incrementally Backup a Drive

使用HoboCopy增量备份驱动器

Hobocopy also supports backing up files incrementally, so it will only copy the files that have changed since the last backup. This works similarly to utilities like rsync, except hobocopy stores the last backup date in a file that you need to specify on the command line.

Hobocopy还支持增量备份文件,因此它将仅复制自上次备份以来已更改的文件。 这类似于rsync之类的实用程序,不同之处在于hobocopy将最后备份日期存储在您需要在命令行上指定的文件中。

/statefile=filenameThis flag specifies the file that contains the last backup information.
/incrementalOnly copy files that have changed since the last full copy.
/ statefile =文件名 该标志指定包含最后备份信息的文件。
/增加的 仅复制自上次完整复制以来已更改的文件。

Syntax:

句法:

hobocopy /incremental /statefile=filename /y /r c:\directoryname\ d:\backupdirectory\

hobocopy / incremental / statefile =文件名/ y / rc:\目录名\ d:\备份目录\

Example:

例:

hobocopy /incremental /statefile=d:\lastbackup.dat /y /r c:\users\geek\ d:\backups\

hobocopy / incremental /statefile=d:\lastbackup.dat / y / rc:\ users \ geek \ d:\ backups \

The first time that you run this command you will need to use /full instead of /incremental, or else you will get an error because the state file hasn’t been created yet. After that you can run the incremental backup with the /incremental switch.

第一次运行此命令时,您将需要使用/ full而不是/ incremental,否则您将收到错误消息,因为尚未创建状态文件。 之后,您可以使用/ incremental开关运行增量备份。

This would be an excellent way to automatically backup a set of folders as part of a scheduled task.

这是作为计划任务的一部分自动备份一组文件夹的绝佳方法。

Download HoboCopy from sourceforge.net

从sourceforge.net下载HoboCopy

翻译自: https://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/

linus备份文件命令行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值