在Windows命令提示符下管道数据

时间:2022-05-11 17:31:28

I need to get a backup dump of a large (~8gb) svn repository. My current method involves using svnadmin dump to a file and then using 7-Zip to compress and split the file.

我需要获得一个大型(~8gb)svn存储库的备份转储。我当前的方法涉及使用svnadmin转储到文件,然后使用7-Zip压缩和拆分文件。

> svnadmin dump c:\path\to\myrepo > c:\svndump.svn
> 7z svndump.svn svndump.7z      // or whatever the correct syntax is

I was wondering if there would be a way to skip the middle-man here, and get the svn dump data to be compressed in one go by using pipes or something? Is this possible? What would the syntax be?

我想知道是否有办法在这里跳过中间人,并通过管道或其他东西一次性压缩svn转储数据?这可能吗?语法是什么?

2 个解决方案

#1


svnadmin dump dumps to standard out by default and the 7z command line can read from standard input using the -si switch.

svnadmin dump默认转储为标准输出,7z命令行可以使用-si开关从标准输入读取。

svnadmin dump c:\path\to\myrepo | 7z a -si svndump.7z

#2


Because your sample was exactly what I was looking for, this is what I did as a complete solution to "dump" all my repositories. That solution dump all svn repositories to 7-zip file without uncompressed intermediate.

因为您的样本正是我所寻找的,所以这就是我作为“转储”所有存储库的完整解决方案所做的。该解决方案将所有svn存储库转储到7-zip文件而不使用未压缩的中间件。

Put that batch file in your "repository root", e.g. m:\repositories\dump-all.bat

将该批处理文件放在“存储库根目录”中,例如米:\库\转储all.bat

pushd %~dp0
SET SEVENZIP="c:\Program Files\7-Zip\7z.exe" a -mx1 -si 
FOR /f "tokens=*" %%i in ('DIR /a:d /b') DO svnadmin dump %%i | %SEVENZIP% ..\_svndump\%%i.dump.7z

And, start that batch like this if you need to run it in low priority, both process (7z + svnadmin) will take a lot of cpu

并且,如果你需要以低优先级运行它,那么启动那个批处理,这两个进程(7z + svnadmin)将占用大量的cpu

start /low m:\repositories\dump-all.bat

Notes: "pushd %~dp0" set the "current directory" to where the batch file is, instead of starting it in "c:\windows\system32" if you start it from explorer with "run as administrator". It also works if the working folder is on another drive.
No need to type "m:" and "cd \repositories". if you start it from "c:" drive.

注意:“pushd%~dp0”将“当前目录”设置为批处理文件所在的位置,而不是在“c:\ windows \ system32”中启动它,如果您使用“以管理员身份运行”从资源管理器启动它。如果工作文件夹位于另一个驱动器上,它也可以工作。无需键入“m:”和“cd \ repositories”。如果你从“c:”驱动器启动它。

#1


svnadmin dump dumps to standard out by default and the 7z command line can read from standard input using the -si switch.

svnadmin dump默认转储为标准输出,7z命令行可以使用-si开关从标准输入读取。

svnadmin dump c:\path\to\myrepo | 7z a -si svndump.7z

#2


Because your sample was exactly what I was looking for, this is what I did as a complete solution to "dump" all my repositories. That solution dump all svn repositories to 7-zip file without uncompressed intermediate.

因为您的样本正是我所寻找的,所以这就是我作为“转储”所有存储库的完整解决方案所做的。该解决方案将所有svn存储库转储到7-zip文件而不使用未压缩的中间件。

Put that batch file in your "repository root", e.g. m:\repositories\dump-all.bat

将该批处理文件放在“存储库根目录”中,例如米:\库\转储all.bat

pushd %~dp0
SET SEVENZIP="c:\Program Files\7-Zip\7z.exe" a -mx1 -si 
FOR /f "tokens=*" %%i in ('DIR /a:d /b') DO svnadmin dump %%i | %SEVENZIP% ..\_svndump\%%i.dump.7z

And, start that batch like this if you need to run it in low priority, both process (7z + svnadmin) will take a lot of cpu

并且,如果你需要以低优先级运行它,那么启动那个批处理,这两个进程(7z + svnadmin)将占用大量的cpu

start /low m:\repositories\dump-all.bat

Notes: "pushd %~dp0" set the "current directory" to where the batch file is, instead of starting it in "c:\windows\system32" if you start it from explorer with "run as administrator". It also works if the working folder is on another drive.
No need to type "m:" and "cd \repositories". if you start it from "c:" drive.

注意:“pushd%~dp0”将“当前目录”设置为批处理文件所在的位置,而不是在“c:\ windows \ system32”中启动它,如果您使用“以管理员身份运行”从资源管理器启动它。如果工作文件夹位于另一个驱动器上,它也可以工作。无需键入“m:”和“cd \ repositories”。如果你从“c:”驱动器启动它。