我需要將大量檔案從 FTP 伺服器傳輸到新伺服器。可能有數千個文件,所以我想將其限制為過去三個月內上傳的文件 - 這可能嗎?
另外,在開始實際下載之前是否可以了解下載的大小?
謝謝
答案1
您可以使用lftp
為此,利用其mirror
命令。這是線上說明頁面的一個片段:
mirror [OPTS] [source [target]]
Mirror specified source directory to local target directory. If target
directory ends with a slash, the source base name is appended to
target directory name. Source and/or target can be URLs pointing to
directories.
[cut...]
-N, --newer-than=SPEC download only files newer than specified time
--on-change=CMD execute the command if anything has been changed
--older-than=SPEC download only files older than specified time
[...]
一定要看看手冊,因為確實有很多有用的選項mirror
- 例如--allow-chown
或--allow-suid
例如--parallel[=N]
。 Lftp 也可以與其他存取協定一起使用,例如sftp
、fish
或http(s)
。
答案2
您可以嘗試使用以下命令將其安裝為檔案系統curlftpfs
。
然後使用複製find
。
例如:
mkdir /tmp/mountpoint
curlftpfs ftp://example.com/ /tmp/mountpoint/
cd /tmp/mountpoint
find -mtime +90 -exec cp {} /dest/path/ \;
我懷疑有更好的解決方案。