bkpdrive
CLI · QuickstartCLI · 快速上手

Your drive, from the terminal.你的雲端硬碟,就在終端機。

bkp is the bkpdrive command-line client — upload, download, list, and manage your files from any shell. One static binary, no dependencies.bkp 是 bkpdrive 的命令列客戶端,在任何 shell 上傳、下載、列出、管理你的檔案。單一靜態執行檔,零相依。

01Install安裝

macOS, Linux, and WSL — one line. It detects your OS and architecture and drops a single binary on your PATH.macOS、Linux、WSL,一行搞定。它會偵測你的作業系統與架構,把單一執行檔放上你的 PATH

$ curl -fsSL https://bkpdrive.com/cli/install.sh | sh

Windows: download bkp-windows-amd64.exe and put it on your PATH. Prefer a custom location? BKP_INSTALL_DIR=~/.local/bin curl … | sh.Windows:下載 bkp-windows-amd64.exe 放上 PATH。想放在別的位置?BKP_INSTALL_DIR=~/.local/bin curl … | sh

02Sign in登入

Run bkp login once. It emails a one-time code to your account address; type it back and bkp saves a refresh token to ~/.bkpdrive/config.json (readable only by you). No browser, and nothing to create on the web first.跑一次 bkp login 就好。它會寄一組一次性驗證碼到你的帳號信箱,把碼打回去,bkp 就會把 refresh token 存進 ~/.bkpdrive/config.json(只有你讀得到)。不必開瀏覽器,也不必先在網頁上建立任何東西。

  1. Log in with your email, then the code from your inbox:登入:輸入信箱,再輸入收到的驗證碼:
    $ bkp login
    Email: you@example.com
    We sent a code to you@example.com. It is valid for 15 minutes.
    Code: 482850
    Logged in as you@example.com (you)

    The code can take up to 10 minutes to arrive; check your spam folder too. A first-time address creates the account and asks you to pick a display name. bkp login --email you@example.com skips the email prompt (so does BKPDRIVE_EMAIL).驗證碼最久可能要 10 分鐘才會到,也記得看一下垃圾郵件匣。第一次使用的信箱會直接建立帳號,並問你要用什麼顯示名稱。bkp login --email you@example.com 可以省去輸入信箱那一步(BKPDRIVE_EMAIL 也可以)。

  2. Verify you're connected:驗證連線:
    $ bkp whoami && bkp quota
Scripts & automation: there is no standing secret to hand a script. Every login needs a fresh code from your inbox. Log in once on a machine where you can read that email, then copy ~/.bkpdrive/config.json to the unattended one. The saved token renews itself on every command, so a machine that runs bkp regularly stays signed in; one left idle for 30 days needs a fresh bkp login. Every command also takes --json for machine-readable output.腳本與自動化:沒有可以直接交給腳本的長期密鑰,每次登入都需要信箱裡的新驗證碼。請在讀得到信的機器上登入一次,再把 ~/.bkpdrive/config.json 複製到無人值守的那台。存下來的憑證每執行一個指令就會自動續期,所以固定在跑的機器會一直保持登入;閒置滿 30 天的則需要重跑一次 bkp login。每個指令都支援 --json 輸出機器可讀格式。

03Usage使用

Address files by name or by a /path (e.g. /photos/trip.zip) — no ids to copy around. Set a working folder with cd and relative paths resolve against it, just like a shell.名稱/path(例如 /photos/trip.zip)指定檔案,不用到處複製 id。用 cd 設定工作資料夾後,相對路徑就像在 shell 裡一樣解析。

bkp cd [path]Set the working folder (no arg → root). Relative .. works.設定工作資料夾(不帶參數 → 根目錄)。支援相對 ..
bkp pwdPrint the current working folder.顯示目前的工作資料夾。
bkp ls [path]List names like ls. -l details · -a hidden · --trash · --recent.ls 一樣列出名稱。-l 詳細 · -a 隱藏檔 · --trash · --recent
bkp tree [path]Show a folder as a tree. -L <depth> to limit.以樹狀顯示資料夾。-L <depth> 限制深度。
bkp ul <file> [dest]Upload a local file (into an optional folder). -r for a whole directory.上傳本地檔案(可指定目的資料夾)。-r 上傳整個目錄。
bkp dl <path> [-o out]Download a file. -o - → stdout · -r for a whole folder.下載檔案。-o - → stdout · -r 整個資料夾。
bkp mkdir <name>Create a folder.建立資料夾。
bkp mv <src> <dest>Move or rename.移動或重新命名。
bkp rm [-r] <path>…Delete to trash (-r for folders).刪除到垃圾桶(資料夾用 -r)。
bkp quotaStorage used and available.已用與可用空間。
bkp whoamiWho you're signed in as.目前登入的帳號。
bkp upgradeUpdate bkp to the latest version in place (--check to peek first).就地把 bkp 更新到最新版(--check 先查看)。

Exit codes: 0 ok · 2 usage · 3 auth · 4 not found · 5 quota · 6 error · 7 network. Large uploads are split and streamed automatically.結束代碼:0 正常 · 2 用法 · 3 認證 · 4 找不到 · 5 配額 · 6 錯誤 · 7 網路。大檔上傳會自動分塊串流。

Tab completion is set up by the installer — press to complete folder and file names (cd completes folders only). Load it in your current shell with source <(bkp completion zsh) (or bash/fish).Tab 補完由安裝器自動設定,按 補完資料夾與檔名(cd 只補資料夾)。要在目前的 shell 立即載入:source <(bkp completion zsh)(或 bash/fish)。

04Examples範例

Everyday flows.日常操作。

# set a working folder and upload into it
$ bkp cd /backups
$ bkp ul ~/db.dump .
$ bkp ls
# make a folder and upload into it
$ bkp mkdir reports
$ bkp ul ~/q3-report.pdf /reports
$ bkp ls /reports
# download by path (or by id)
$ bkp dl /reports/q3-report.pdf -o ./q3.pdf
# back up a directory as an archive
$ tar czf project.tar.gz ~/project
$ bkp ul ./project.tar.gz
# scripting on an unattended box: carry the credential file over,
# then no login is needed there
$ scp ~/.bkpdrive/config.json ci-box:~/.bkpdrive/config.json
$ ssh ci-box "bkp --json ls | jq -r '.files[].id'"