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.
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
This tool's name is a bit misleading, it can handle either FTP or SFTP.
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user ftp://ftp.server.com
$ lftp -e "mirror -c /download/<dir> /local/<dir>" -u user sftp://sftp.server.com
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
set ftp:list-options -L
$ lftp -e "set ftp:list-options -L; mirror -c /download/<dir> /local/<dir>" \ -u user ftp://ftp.server.com
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.
To resume the transfer of a single file, this seems to work:
In your local directory, get the size of the file that was already partially downloaded with:
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
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.
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:firstname.lastname@example.org/dir/upload.zip --20:14:23-- `upload.zip' => ftp://login:email@example.com:21/dir/upload.zip Connecting to 126.96.36.199: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 188.8.131.52: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