명령행에서 AWS, Azure 등의 원격 저장소에 파일 관리하는 방법 - cyberduck/duck 소개
회사 동료를 통해 cyberduck이라는 제품을 알게 되었습니다. ^^
cyberduck
; https://cyberduck.io/
위의 링크 글에서도 나오지만 "FTP, SFTP, WebDAV, Amazon S3, OpenStack Swift, Backblaze B2, Microsoft Azure & OneDrive, Google Drive and Dropbox."에 대한 파일 관리를 해주는 통합 도구인데요, 아쉽게도 cyberduck이 명령행을 지원하지 않습니다.
대신 별도로 duck이라는 도구로 제공하는데요, 윈도우의 경우 패키지 관리자로써 새롭게 떠오르고 있는 chocolatey을,
The package manager for Windows
Chocolatey - Software Management Automation
; https://chocolatey.org/
; https://chocolatey.org/install
설치한 다음,
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
간단하게 duck 도구를 내려받을 수 있습니다.
choco install duck
사용법은 스토리지 별로 달라지는데,
Cyberduck Help / Howto / Command Line Interface (CLI)
; https://trac.cyberduck.io/wiki/help/en/howto/cli
위의 문서에 따라, 예를 들어 아마존이라면 스토리지에 대한 "Access key ID"를 구해 다음과 같이 실행하면 파일 업로드가 됩니다.
[형식]
duck --username "...[access key id]..." --upload s3:...[server path]... ...[client path]... --existing overwrite
[사용 예]
Access key ID: FAICA5IZ72CDKSLNM96DQ
서버 측 경로: /test-stg/my
클라이언트 측 업로드할 파일 경로: c:\temp\test.zip
duck --username "FAICA5IZ72CDKSLNM96DQ" --upload s3:/test-stg/my/test.zip c:\temp\test.zip --existing overwrite
[사용 예 - 목록]
duck --username "FAICA5IZ72CDKSLNM96DQ" --list s3:/test-stg/my
[사용 예 - 삭제]
duck --username "FAICA5IZ72CDKSLNM96DQ" -D s3:/test-stg/my/test.zip
참고로, Chocolatey에서 cyberduck 제품도 설치할 수 있습니다.
Cyberduck (Install)
; https://chocolatey.org/packages/cyberduck.install
choco install cyberduck.install
[2020-06-23 내용 추가]
만약 다음과 같은 오류가 발생한다면?
C:\> duck --username "..." --password "..." --list s3://mycontainer/mystore
Resolving mycontainer
Connection failed. DNS lookup for mycontainer failed. DNS is the network service that translates a server name to its Internet address. This error is most often caused by having no connection to the Internet or a misconfigured network. It can also be caused by an unresponsive DNS server or a firewall preventing access to the network.
그것은... ^^ s3의 주소를 "s3://"와 같은 식으로 했기 때문입니다. "s3:/"로 슬래시 문자를 하나만 넣어야 합니다.
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]