Source Types
Cloudstic provides two Google Drive source types:gdrive— Full scan (lists all files on every backup)gdrive-changes— Incremental (uses Changes API, recommended)
Use
gdrive-changes for faster incremental backups. It only fetches changes since the last backup, making subsequent backups significantly faster.Basic Usage
First-Time Setup
On your first backup, Cloudstic will open your browser to authenticate with Google:~/.config/cloudstic/google_token.json and automatically reused for future backups.
Incremental Backups (Recommended)
Use the Changes API for faster backups:Configuration Options
Source Flags
| Flag | Description | Environment Variable |
|---|---|---|
-source gdrive | Full scan source | CLOUDSTIC_SOURCE |
-source gdrive-changes | Incremental source (recommended) | CLOUDSTIC_SOURCE |
-drive-id <id> | Shared Drive ID (omit for My Drive) | CLOUDSTIC_DRIVE_ID |
-root-folder <id> | Root folder ID (defaults to entire drive) | CLOUDSTIC_ROOT_FOLDER |
Authentication
| Environment Variable | Description |
|---|---|
GOOGLE_APPLICATION_CREDENTIALS | Path to service account credentials JSON (optional) |
GOOGLE_TOKEN_FILE | Path to OAuth token file (default: ~/.config/cloudstic/google_token.json) |
Optional Flags
| Flag | Description |
|---|---|
-exclude <pattern> | Exclude pattern (gitignore syntax, repeatable) |
-exclude-file <path> | Load exclude patterns from file |
-tag <tag> | Tag to apply to the snapshot (repeatable) |
-dry-run | Scan source without writing to store |
Examples
Backup My Drive
Back up your entire Google Drive:Backup a Shared Drive
Back up a Shared Drive by ID:To find a Shared Drive ID, open the drive in your browser and copy the ID from the URL:
https://drive.google.com/drive/folders/[DRIVE_ID]Backup Specific Folder
Restrict backup to a specific folder:Backup with Exclusions
Exclude specific folders or file types:Backup with Tags
Authentication Methods
Cloudstic supports two authentication methods for Google Drive:1. OAuth 2.0 (Default, Recommended)
How it works:
Permissions requested:
https://www.googleapis.com/auth/drive.readonly— Read-only access to your files
2. Service Account (Advanced)
For automated backups without user interaction, use a service account:Create service account
In Google Cloud Console:
- Go to IAM & Admin > Service Accounts
- Create a new service account
- Download the JSON key file
OAuth Flow Details
First Backup
When you run your first backup:- Browser opens — Cloudstic starts a local HTTP server and opens your browser
- Google consent — You sign in and grant permissions
- Automatic callback — The authorization code is captured automatically
- Token exchange — Cloudstic exchanges the code for an access token
- Token saved — Token is saved to
~/.config/cloudstic/google_token.json - Backup starts — Files are scanned and backed up
Subsequent Backups
- Token loaded — Existing token is read from disk
- Automatic refresh — If expired, the token is refreshed using the refresh token
- Backup starts — No browser interaction needed
Token Location
By default, tokens are stored at:- Linux/macOS:
~/.config/cloudstic/google_token.json - Windows:
%APPDATA%\cloudstic\google_token.json
How It Works
Full Scan (gdrive)
Incremental Scan (gdrive-changes)
Subsequent backups
Uses the Changes API to fetch only modified/added/deleted items since the last token.
File Identification
Google Drive files are identified by their Drive file ID:- File ID:
1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVwQA - Name:
report.pdf - Path:
Documents/report.pdf(computed from parent relationships)
Content Deduplication
Cloudstic uses Google Drive’s SHA-256 checksums to avoid re-uploading unchanged files:- If the checksum matches, the file is skipped
- Only changed files are downloaded and backed up
Source Information
Each snapshot records:- Type:
gdriveorgdrive-changes - Account: Google account email (e.g.,
user@gmail.com) - Path:
my-drive://or<driveID>://<rootFolderID>
Performance Considerations
Full Scan Performance
- First backup: 10-50 files/second (limited by API rate limits)
- API calls: ~2 requests per 1000 files
- Bottleneck: Network latency and API quotas
Incremental Performance
- Small changes: Completes in seconds (only fetches changes)
- Large changes: Proportional to number of changed files
- Recommended: Use
gdrive-changesfor faster backups
API Rate Limits
Google Drive API has rate limits:- Queries per 100 seconds: 1000 (per user)
- Queries per day: 1,000,000,000 (per project)
Google Drive Specifics
Google Workspace Files
Google Workspace files (Docs, Sheets, Slides) are not backed up as binary files because:- They don’t have a native binary format
- They can be exported, but formats vary
- They’re stored in Google’s proprietary format
To back up Google Workspace files:
- Export them to standard formats (PDF, DOCX, XLSX) manually
- Store exports in a regular Drive folder
- Back up the exported files
Folder Structure
Google Drive allows files to have multiple parents. Cloudstic handles this by:- Choosing the first parent when computing paths
- Storing all parent IDs in metadata
- Preserving the file under its primary path
Trashed Files
Trashed files are automatically excluded from backups. Only files in your Drive (not in Trash) are backed up.Common Use Cases
Personal Backup
Shared Drive Backup
Selective Folder Backup
Automated Backups
Use a service account for automated backups:Troubleshooting
Authentication Failed
- Delete the token file and re-authenticate:
- Check that you have internet connectivity
- Verify Google Drive API is enabled in your project (for service accounts)
Rate Limit Exceeded
- Cloudstic automatically retries with exponential backoff
- Wait a few minutes and try again
- For frequent backups, use
gdrive-changesinstead ofgdrive
Permission Denied
- Ensure you granted the
drive.readonlyscope during OAuth - For Shared Drives, ensure you have access to the drive
- For service accounts, share the drive/folders with the service account email
Slow Backups
If backups are taking too long:- Switch to
gdrive-changesfor incremental backups - Use
-root-folderto limit scope - Add exclude patterns to skip unnecessary folders
- Check API quotas in Google Cloud Console