哦!由于我的网络连接速度很慢,我陷入了困境。我正在通过 ftp 将视频文件从本地上传到远程。但是网络失败。我知道有一个名为 reget 的命令可以恢复下载,但是有没有任何命令可以恢复上传。?如果没有,那么我就被击中了。
答案1
我总是使用lftp
能够恢复中途终止或我想取消并稍后重新启动的下载的客户端。
我通常使用这样的命令:
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user -p <port> ftp.server.com
还有什么?
这个工具的名字有点误导,它可以处理 FTP 或 SFTP。
文件传输协议
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user ftp://ftp.server.com
sftp
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user sftp://sftp.server.com
镜像链接
有时您可能会遇到包含符号链接的镜像目录的问题,要解决此问题,您可以将此选项添加到命令中lftp
:
set ftp:list-options -L
例如:
$ lftp -e "set ftp:list-options -L; mirror -c /download/<dir> /local/<dir>" \
-u user ftp://ftp.server.com
参考
答案2
lftp 还有“reput”命令,它可以为您执行 SIZE 和 REST
lftp user:pass@host/path/to/folder
cd ok, cwd=/path/to/folder
lftp user@host:/path/to/folder> reput file.ext
---> TYPE I
<--- 200 Type set to I
---> SIZE file.ext
<--- 213 11842837120
---> PASV
<--- 227 Entering Passive Mode (10,211,14,15,220,70).
---- Connecting data socket to (10.211.14.15) port 56390
---- Data connection established
---> ALLO 20769244058
<--- 202 No storage allocation necessary
---> REST 11842837120
<--- 350 Restarting at 11842837120. Send STORE or RETRIEVE to initiate transfer
---> STOR file.ext
<--- 150 Opening BINARY mode data connection for file.ext
`file.ext' at 6756302848 (32%) 31.50M/s eta:7m [Sending data]
答案3
要使用内置 ftp 命令恢复单个文件上传,您需要知道已发送的文件有多少字节。这应该可以通过使用来访问ls
。然后,您使用以下序列重新开始上传,替换<#>
为已发送的字节数和<filename>
您要上传的文件名。
restart <#>
put <filename>
如果服务器允许,您应该会收到如下消息......
350 Restart position accepted (<#>).
150 Ok to send data.
这将恢复您的上传。
答案4
可能是我太垃圾,无法配置远程传输协议正确地,这就是为什么我更喜欢写入量。以下是 wput 在连接出现问题后如何继续上传的示例:
wput -v -u -B upload.zip ftp://login:[email protected]/dir/upload.zip
--20:14:23-- `upload.zip'
=> ftp://login:[email protected]:21/dir/upload.zip
Connecting to 111.111.111.111:21... connected!
Logging in as login ... Logged in!
==> CWD dir
==> TYPE I ... done.
==> SIZE upload.zip ... done (4313 bytes)
==> PASV ... done.
==> REST 3584 ... done.
==> STOR upload.zip ... done.
Length: 902,153,406 [902,149,822 to go]
7% [======> ] 65,658,368 194.0K/s ETA 1:10hError: Error encountered during uploading data (Operation now in progress)
==> ABOR ... Error: recv() timed out. No data received
Receive-Warning: read() timed out. Read '' so far.
failed.
Waiting 10 seconds... Error: recv() timed out. No data received
Receive-Warning: read() timed out. Read '' so far.
Connecting to 111.111.111.111:21... connected!
Logging in as login ... Logged in!
==> CWD dir
==> TYPE I ... done.
==> SIZE upload.zip ... done (65247144 bytes)
==> PASV ... done.
==> REST 65246208 ... done.
==> STOR upload.zip ... done.
Length: 902,153,406 [836,907,198 to go]
9% [++++++==>
为了完全公平,这是我尝试使用 lftp 来完成相同的任务:
lftp -e "set net:timeout 10; set ssl:check-hostname false; set ssl:verify-certificate false; put -c -O /dir upload.zip; bye" -u login,password server.com