简体   繁体   English

通过SSH将一个文件夹压缩成多个文件

[英]tar a folder into multiple files over SSH

Here is the thing 这是东西

I have a server with total 85 GB disk space and right now i have a folder with the size of 50 GB which is containing over 60000 files . 我有一台服务器,总共有85 GB的磁盘空间,现在我有一个50 GB的文件夹,其中包含60000个文件。

Now i want to download these files on my localhost and in order to do that i need to tar the folder but I can't tar the whole folder because of disk space limitation. 现在,我想在本地主机上下载这些文件,然后为此我需要对文件夹进行tar压缩,但是由于磁盘空间限制,我无法对整个文件夹进行tar压缩。

So i'm looking for a way to archive the folder into two 25 GB tar file like part1.tar and part2.tar but when the first part is done it should wait for asking something like next part name or permission or anything so I can transfer the first part to an another server and then continue archiving to part2. 因此,我正在寻找一种将文件夹存档为两个25 GB的tar文件(如part1.tar和part2.tar)的方法,但是当完成第一部分时,它应该等待询问类似下一个部分的名称或权限之类的内容,这样我就可以将第一部分转移到另一台服务器,然后继续归档到第二部分。 Or a way to tar half of the folder like first 30000 files and then tar the rest. 或者一种将文件的一半压缩的文件,例如前30000个文件,然后将其余文件压缩。

Any idea? 任何想法? Thanks in advance 提前致谢

One of the earliest applications of rsync was to implement mirroring or backup for multiple Unix clients to a central Unix server using rsync/ssh and standard Unix accounts. rsync的最早应用之一是使用rsync / ssh和标准Unix帐户将多个Unix客户端实现镜像或备份到中央Unix服务器。

I use rsync to move compressed (and uncompressed) files between servers. 我使用rsync在服务器之间移动压缩(和未压缩)文件。

I think the command should be something like this 我认为命令应该是这样的

rsync -av host::src /dest

rsync solution was good enough but i found the solution for main question: rsync解决方案足够好,但我发现了主要问题的解决方案:

tar -c -M --tape-length=30000000 --file=filename.tar foldername

After reaching 29GB you will need to change the tape(in my case transferring the first part and removing it) and hit enter for continue.Additionally it is possible for give next parts name: 达到29GB后,您需要更换磁带(在我的情况下,是转移第一部分并取出它),然后按Enter键以继续。此外,还可以指定下一个部分的名称:

Prepare volume #2 for `filename.tar' and hit return:

n filename2.tar

Because it is going to take time i suggest using screen session over SSH : http://thelinuxnoob.com/linux/screen-in-ssh/ 因为这将花费时间,所以我建议通过SSH使用屏幕会话: http : //thelinuxnoob.com/linux/screen-in-ssh/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM