Skip to content

miketropi/wpb-upload-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPB Upload CLI

A command-line tool for uploading large files to WordPress sites using the Worry-Proof Backup plugin. This tool automatically chunks large files, uploads them in parallel, and triggers the restore process on the server.

Features

  • 📦 Chunked Uploads: Automatically splits large files into manageable chunks
  • Parallel Processing: Uploads multiple chunks concurrently for faster transfers
  • 📊 Progress Tracking: Real-time progress bar showing upload status
  • 🔄 Auto-Restore: Automatically triggers the unzip/restore process after upload completes
  • 🔐 Secure Authentication: Uses Basic Auth with token-based authentication

Installation

Using npx (Recommended - No Installation Required)

You can use the tool directly with npx without installing it:

npx github:miketropi/wpb-upload-cli upload --file <path> --site <url> --token <token> [options]

Usage

With npx (No Installation)

npx github:miketropi/wpb-upload-cli upload --file <path> --site <url> --token <token> [options]

Required Options

  • --file <path> - Path to the file you want to upload
  • --site <url> - WordPress site URL (e.g., https://example.com)
  • --token <token> - Your WordPress application's credentials in the format "username:application_password"

Optional Options

  • --chunk-size <mb> - Chunk size in megabytes (default: 10)
  • --concurrency <n> - Number of parallel uploads (default: 3)

Examples

Basic Upload (using npx)

npx github:miketropi/wpb-upload-cli upload \
  --file ./backup.zip \
  --site https://example.com \
  --token "username:application_password"

Custom Chunk Size and Concurrency

npx github:miketropi/wpb-upload-cli upload \
  --file ./large-backup.zip \
  --site https://example.com \
  --token "username:application_password" \
  --chunk-size 20 \
  --concurrency 5

Upload with Smaller Chunks (for slower connections)

npx github:miketropi/wpb-upload-cli upload \
  --file ./backup.zip \
  --site https://example.com \
  --token "username:application_password" \
  --chunk-size 5 \
  --concurrency 2

Note: If you've installed the package globally, you can omit npx and use wpb-upload-cli directly.

How It Works

  1. Chunking: The file is split into chunks based on the specified chunk size
  2. Upload: Chunks are uploaded in parallel to the WordPress site's REST API endpoint
  3. Progress: A progress bar shows the upload status in real-time
  4. Restore: Once all chunks are uploaded, the tool automatically triggers the restore/unzip process on the server
  5. Completion: The process completes when the server finishes extracting the uploaded file

API Endpoints

The tool communicates with the following WordPress REST API endpoints:

  • POST /wp-json/worry-proof-backup/v1/upload-chunk - Uploads individual chunks
  • POST /wp-json/worry-proof-backup/v1/restore-start - Initializes the restore process
  • POST /wp-json/worry-proof-backup/v1/restore-run - Executes the restore process

Error Handling

  • 413 Payload Too Large: If you encounter this error, reduce the --chunk-size option
  • Upload Failures: The tool will stop and display an error message if any chunk fails to upload
  • Network Errors: Connection issues are reported with detailed error messages

Requirements

  • Node.js (ES modules support required)
  • WordPress site with Worry-Proof Backup plugin installed
  • Valid authentication token for the WordPress site

Dependencies

  • axios - HTTP client for API requests
  • commander - CLI framework
  • form-data - Form data handling for multipart uploads
  • p-queue - Promise queue for managing concurrent uploads
  • cli-progress - Progress bar display

License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors