Is there any ftp command to resume upload?
I always use the lftp
client which has the ability to resume a download that either died midstream or that I want to cancel and later restart.
I usually use the command like so:
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user -p <port> ftp.server.com
What else?
This tool's name is a bit misleading, it can handle either FTP or SFTP.
ftp
$ 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
Mirroring Links
From time to time you might encounter a issue with mirroring directories that contain symlinks, to work around this issue you can add this option to your lftp
command:
set ftp:list-options -L
For eg:
$ lftp -e "set ftp:list-options -L; mirror -c /download/<dir> /local/<dir>" \
-u user ftp://ftp.server.com
References
- lftp man page
- Re: [lftp] Mirror not detecting change in remote symlinked file
lftp also has the "reput" command, which does the SIZE and REST for you
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]
To resume a single file upload using the built-in ftp command you will need to know how many bytes of the file you have already sent. This should be accessible by using ls
. Then you use the following sequence to restart your upload replacing <#>
with the number of bytes already sent and <filename>
with the filename you are uploading.
restart <#>
put <filename>
If the server allows it you should receive a message such as the following...
350 Restart position accepted (<#>).
150 Ok to send data.
This will resume your upload.