【问题标题】:How to copy more than 5k files with FTP client from linux server如何使用 FTP 客户端从 linux 服务器复制超过 5k 的文件
【发布时间】:2016-01-04 18:43:12
【问题描述】:

我需要备份网站的 FTP。该站点托管在 linux 服务器上。问题是有一个包含超过 5k 个文件的文件夹。 Linux 不能显示超过 4998 个文件,所以我不能复制这些文件,因为服务器不给我超过 4998 个。 我无法删除这些文件以查看其他文件,因为该站点实际上是在线的。出于同样的原因,我无法将这些文件移动到另一个目录中。

我能做什么?我正在尝试使用外壳...但我不知道...我不确定是否使用此方法。

【问题讨论】:

  • SSH 是一种选择吗?您可以将所有文件复制到第二个目录,然后从那里下载和删除吗?您的客户端上运行哪个操作系统?
  • SSH 不是一个选项,它是一个虚拟主机,我无法访问 SSH。我在优胜美地,我正在使用 Yummy FTP。我可以复制等。但我只能为每个文件夹复制 5k 个文件。

标签: ftp server limit


【解决方案1】:

我自己的答案得到了解决方案

 <?php
$rootPath = realpath('wp-content/uploads/2014/07');

// Initialize archive object
$zip = new ZipArchive();
$zip->open('dio.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);

// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($rootPath),
    RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file)
{
    // Skip directories (they would be added automatically)
    if (!$file->isDir())
    {
        // Get real and relative path for current file
        $filePath = $file->getRealPath();
        $relativePath = substr($filePath, strlen($rootPath) + 1);

        // Add current file to archive
        $zip->addFile($filePath, $relativePath);
    }
}

// Zip archive will be created only after closing object
$zip->close();

【讨论】:

    【解决方案2】:

    您可以通过命令行执行此操作,本指南shows you how。递归调用(子文件夹及其内容)似乎不推荐使用mget(ftp命令),所以也可以使用wget,se this

    我还喜欢将包含许多文件的此类文件夹压缩为一个,以便在上传和下载时进行监督。使用

    zip -r myfiles.zip myfiles
    

    这是guide for that too

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 2014-10-16
      • 1970-01-01
      • 1970-01-01
      • 2020-04-17
      • 1970-01-01
      相关资源
      最近更新 更多