6

Oh! with my slow net connection, I am badly stuck. I was uploading a video file from local box to remote one via ftp. But net failed.I know there is a command named reget to resume download but Is there any command to resume upload.? If no then I am hit.

  • You can try to use the REST command followed by STOR. In theory it should work, but I never used it myself. – Marco Sep 20 '13 at 13:09
  • 1
    wput is an uploader that matches wiht wget so it can continue interrupted uploads... – ivanivan Jul 13 '17 at 12:31
8

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

  • Great!!working superb!! Many thanks to you slm. The display is very nice as it is showing the rate of transfer, how much downloaded, estimated time left, etc. – Ravi Sep 20 '13 at 15:39
  • @Ravi - yeah it's the best terminal ftp/sftp client I've found thus far. I often have to do downloads that take 1-2 weeks so running it inside of screen makes it easy to come back and check on it, but leave it running. Please accept this answer if you think it solves your Q, and thanks for the Q's. – slm Sep 20 '13 at 15:40
  • (I am sorry) as I am new to this site, I wasn't aware that there is specific way to mark this answer as accepted. Now I have come to know and hence marked this as accepted answer. Many many thanks to help me when yesterday I highly needed a solution. – Ravi Sep 21 '13 at 13:02
3

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]   
2

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.

  • Thanks, this was what I needed! Works for downloading (receiving) files too; just use get <filename> instead of put <filename> :) – Doktor J Oct 14 at 17:12
0

To resume the transfer of a single file, this seems to work:

  1. In your local directory, get the size of the file that was already partially downloaded with:

    ls -la
    
  2. Assuming that the folder where the file was partially downloaded is your current directory and that it is at the root of your remote FTP account, adapt the following lftp call to your needs:

    lftp -e "get1 -c --source-region 2000000000-5000000000 --target-position 2000000000 yourfile.ext" -u utilisateur,mot_de_passe ftp.yourserver.ext
    

Running get1 with the -c option resumes the transfer and displays the percentage of the source file that was already downloaded. I haven't finished downloading a resumed file yet, but it seems to be working fine.

  • In case it's not obvious, utilisateur is French for "user" and mot de passe is "password". – tripleee Jul 13 '17 at 15:21
0

Probably, I'm too dump to configure lftp properly and that's why I prefer wput. Here is an example how wput continues upload after connection problems:

wput -v -u -B upload.zip ftp://login:pass@server.com/dir/upload.zip
--20:14:23-- `upload.zip'
    => ftp://login:xxxxx@111.111.111.111: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% [++++++==> 

Just to be completely fair, here is my attempt to use lftp for same task:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.