We have already written about the features of working with our repository via FTP. Today we will touch on a narrower and more specific topic and discuss the specifics of working with the storage using console FTP clients, which are quite often used to organize backup and archiving.
All of these clients have a peculiar and rather complex command syntax. So that our users do not experience difficulties and do not spend time searching through manuals when writing the corresponding scripts, we decided to create a small cheat sheet with examples of commands for performing the most common operations:
- upload files to the repository;
- download files with the ability to resume when the connection is canceled or disconnected;
- synchronization of local files with files in the repository and vice versa.
Lftp
Uploading one file to the repository:
')
$ lftp -e 'cd /container/; put /path/to/local/file; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
(hereinafter, instead of xxxx_ftp we specify the user name, instead of PasSw0rD - our password, containter - container name; instead of / path / to / local / file - the path to the file on the local machine).
Upload folder with all files in it:
$ lftp -e 'mirror -R /path/to/local/dir/ /container/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
(hereinafter instead of / path / to / local / dir / we specify the path to the folder on the local machine).
When the file upload operation is repeated, the contents of the container and the corresponding folder are synchronized on the local machine: only files that were missing at the time of the previous download will be downloaded to the storage.
Using the
–delete option, you can delete files that are no longer on the local machine from the storage. It can be useful for cleaning storage from files that have lost their relevance.
$ lftp -e 'mirror --delete -R /path/to/local/dir/ /container/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
Downloading one file from the repository to the local machine:
$ lftp -e 'get /container/file -o to-dir/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
Resume download (for example, if there was a disconnection or the download operation was interrupted):
$ lftp -e 'get -c /container/file -o to-dir/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
Downloading from the storage folder with all the contents:
$ lftp -e 'mirror /container/ to-dir/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
The
-P option for the previous command allows downloading in several streams, which can speed up the entire operation:
$ lftp -e 'mirror -P 10 /container/ to-dir/; bye' -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
All considered commands can be performed online. Enter interactive mode by using the command:
$ lftp -u xxxx_ftp,PasSw0rD ftp.selcdn.ru
NCFTP
Uploading one file to the repository:
$ ncftpput -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru /container/ /path/to/local/file
NCFTP supports automatic repetition of the operation in case of errors during its execution; to do this, use the
-r option:
Upload folder with all files in it:
$ ncftpput -R -r 5 -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru /container/ /path/to/local/dir/
Synchronize local files with storage:
$ ncftpput -z -R -r 5 -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru /container/ /path/to/local/dir/
Download from single file storage:
$ ncftpget -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru to-dir/ /container/file
Resume download,
-z option:
$ ncftpget -z -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru to-dir /container/file
Uploading folders to the local machine:
$ ncftpget -R -u xxxx_ftp -p PasSw0rD ftp.selcdn.ru to-dir/ /container/dir/
Wget
Downloading a single file to the local machine:
Download file folders to your local machine:
$ wget -r ftp://xxxx_ftp:PasSw0rD@ftp.selcdn.ru/container/dir/
cURL
Uploading one file to the repository:
$ curl ftp://ftp.selcdn.ru/container/ --user xxxx_ftp:PasSw0rD -T /path/to/local/file
Downloading a file to a local machine:
SFTP support
Now our storage also supports access via SFTP protocol - so far in test mode.
We invite all interested readers to try the new opportunity. To connect you need to specify the host
sftp.selcdn.ru . Please inform us about any errors and problems with access via SFTP. All comments and suggestions for improving the service will definitely take note.
Readers who are not able to comment on posts on Habré, we invite to our
blog .