Quick Start
This guide will help you get started with PyDrime quickly.
Initial Setup
Configure your API key
The easiest way to set up PyDrime is using the init command:
pydrime init
This will:
Prompt you for your Drime Cloud API key
Validate the key with Drime Cloud
Store it securely in
~/.config/pydrime/configSet appropriate file permissions (owner read/write only)
Alternative Configuration Methods
Environment Variable:
export DRIME_API_KEY="your_api_key_here"
Configuration File:
Create or edit ~/.config/pydrime/config:
DRIME_API_KEY=your_api_key_here
Command-line Argument:
pydrime --api-key "your_api_key_here" upload myfile.txt
Configuration Priority
The tool checks for API keys in the following order (highest to lowest priority):
Command-line
--api-keyargumentDRIME_API_KEYenvironment variable~/.config/pydrime/configfileLocal
.envfile
Basic Usage
Check Status
Verify your API key and connection:
pydrime status
Upload a File
pydrime upload /path/to/file.txt
Upload to a specific workspace:
pydrime upload /path/to/file.txt --workspace 123
Upload a Directory
pydrime upload /path/to/directory
Specify a remote path:
pydrime upload /path/to/file.txt --remote-path "folder/file.txt"
Advanced Upload Options
Progress Tracking
By default, uploads show an interactive progress bar with file-level details. For CI/CD environments or log files, use simple text progress:
# CI/CD friendly progress (line-by-line updates)
pydrime upload /path/to/directory --simple-progress
# Silent mode (no progress output)
pydrime upload /path/to/directory --no-progress
Parallel Uploads
Speed up directory uploads by uploading multiple files in parallel:
# Upload with 10 parallel workers (default is 5, max is 20)
pydrime upload /path/to/directory -j 10
# Maximum parallelism
pydrime upload /path/to/directory -j 20
Duplicate Handling
Control what happens when a file with the same name already exists:
# Skip existing files (fastest for incremental uploads)
pydrime upload /path/to/directory --on-duplicate skip
# Rename new files as "file (1).txt", "file (2).txt", etc.
pydrime upload /path/to/file.txt --on-duplicate rename
# Replace existing files (old versions moved to trash)
pydrime upload /path/to/file.txt --on-duplicate replace
# Ask interactively for each duplicate
pydrime upload /path/to/directory --on-duplicate ask
Combining Options
# Fast incremental backup: parallel + skip duplicates + simple progress
pydrime upload ./backup -j 10 --on-duplicate skip --simple-progress
# CI/CD deployment: replace old files with silent mode
pydrime upload ./dist --on-duplicate replace --no-progress
List Files
List files in root:
pydrime ls
List files in a specific folder by ID:
pydrime ls 12345
List files in a specific folder by name:
pydrime ls Documents
Search for files:
pydrime ls --query "report"
Download Files
Download a file by name:
pydrime download test.txt
Download a file by hash:
pydrime download abc123hash
Download a file by ID:
pydrime download 480424796
Download a folder (automatically includes all contents):
pydrime download my_folder
Download to a specific location:
pydrime download my_folder --output /path/to/save
Download multiple files:
pydrime download file1.txt file2.txt folder1
Skip existing files (useful for incremental downloads):
pydrime download my_folder --on-duplicate skip
Rename duplicates to keep both versions:
pydrime download test.txt --on-duplicate rename
Overwrite existing files (default):
pydrime download test.txt --on-duplicate overwrite
Create Directory
pydrime mkdir "My Folder"
Create in a specific parent folder:
pydrime mkdir "Subfolder" --parent-id 12345
Rename Files
# Rename by ID
pydrime rename 12345 "New Name.txt"
# Rename by name
pydrime rename "oldname.txt" "newname.txt"
Delete Files
# Delete by ID
pydrime rm 12345
# Delete by name
pydrime rm test.txt
# Delete folder by name
pydrime rm my_folder
Validate Uploads
After uploading files, verify they exist in Drime Cloud with correct sizes:
# Validate a single file
pydrime validate test.txt
# Validate a folder
pydrime validate my_folder
# Validate multiple paths
pydrime validate file1.txt folder1 file2.txt
# Use in scripts (check exit code)
pydrime validate uploaded_files && echo "All files validated successfully"
The validate command is particularly useful for:
Verifying uploads completed successfully
CI/CD pipelines to ensure data integrity
Checking backups match local files
Sync Files
Synchronize local directory with Drime Cloud:
# Default two-way sync
pydrime sync ./my_folder
# Sync with specific remote path
pydrime sync ./docs -r remote_docs
# Using sync modes explicitly
pydrime sync /home/user/docs:twoWay:/Documents
pydrime sync ./backup:localBackup:/Backup
Available sync modes:
twoWay(tw) - Mirror changes in both directionslocalToCloud(ltc) - Upload local changes onlylocalBackup(lb) - Upload to cloud, never deletecloudToLocal(ctl) - Download cloud changes onlycloudBackup(cb) - Download from cloud, never delete
Preview sync changes without syncing:
pydrime sync ./data --dry-run
Find Duplicates
Find and optionally delete duplicate files:
# Show duplicates (dry run)
pydrime find-duplicates
# Find in specific folder
pydrime find-duplicates --folder "My Documents" --recursive
# Actually delete duplicates
pydrime find-duplicates --delete
Storage Usage
Check your storage usage:
pydrime usage
Server Features
WebDAV and REST server functionality has been moved to separate packages:
pywebdavserver - Mount Drime Cloud as a network drive
pyrestserver - Use Drime Cloud as a restic backup destination
Install them separately if needed:
pip install pywebdavserver
pip install pyrestserver
See their respective documentation for usage instructions.
Python API Usage
Basic Example
from pydrime import DrimeClient
from pathlib import Path
# Initialize client
client = DrimeClient(api_key="your_api_key_here")
# Upload a file
result = client.upload_file(Path("myfile.txt"))
print(f"Uploaded: {result}")
# List files
files = client.list_files()
for file in files.get("data", []):
print(f"{file['name']} - {file['type']}")
# Download a file
saved_path = client.download_file("abc123hash")
print(f"Downloaded to: {saved_path}")
Error Handling
from pydrime import DrimeClient, DrimeAPIError, DrimeAuthenticationError
try:
client = DrimeClient(api_key="your_api_key_here")
result = client.upload_file(Path("myfile.txt"))
except DrimeAuthenticationError:
print("Invalid API key!")
except DrimeAPIError as e:
print(f"API error: {e}")
Next Steps
See Command Line Interface for complete CLI reference
See Python API Reference for Python API documentation
See Exception Handling for error handling