Download Files from Google Drive to VPS
Downloading files from Google Drive to a VPS is more complex than usual because Google uses confirmation redirects for large files and requires authentication for private files. Here are the methods that really work.
Method 1: gdown (recommended, public files)
gdown is a Python tool specifically for Google Drive. It automatically handles redirects and confirmation cookies.
# Install gdown
pip install gdown --break-system-packages
# or
pip3 install gdown --break-system-packages
# Download a file via shareable URL
gdown "https://drive.google.com/file/d/FILE_ID/view"
# Or directly with file ID
gdown FILE_ID
# Download to specific directory
gdown FILE_ID -O /root/downloads/
# Download entire folder
gdown --folder https://drive.google.com/drive/folders/FOLDER_ID
How to find the FILE_ID
From the file URL:
https://drive.google.com/file/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/view
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this is the FILE_ID
Method 3: rclone (private files and large folders)
For private files or large folders, rclone is the most robust solution. Requires OAuth authorization once.
# Install rclone
curl https://rclone.org/install.sh | bash
# Configure Google Drive (requires browser once)
rclone config
# Follow the wizard:
# n → new remote
# name: gdrive
# type: drive (Google Drive)
# client_id and secret: leave empty to use rclone's
# scope: 1 (full access) or 2 (read-only)
# Authentication: open link in browser and authorize
After configuration:
# List files in Drive root
rclone ls gdrive:
# Download a specific file
rclone copy "gdrive:Folder/filename.zip" /root/downloads/
# Download entire folder
rclone copy "gdrive:Backup Server" /root/downloads/backup/ --progress
# Sync (deletes files no longer on Drive)
rclone sync "gdrive:Backup" /root/backup/ --progress
# Speed up download with parallel transfers
rclone copy "gdrive:file.zip" /root/ --transfers 8 --progress
If configuring rclone on a VPS without browser, use rclone config and choose "Use auto config? n": it will provide a URL to open on your local PC.
Speed up downloads
Increase parallel transfers with rclone
# Use 16 parallel threads (great for large files or folders)
rclone copy "gdrive:Backup" /root/backup/ \
--transfers 16 \
--checkers 8 \
--buffer-size 256M \
--drive-chunk-size 128M \
--progress
Check actual speed
# Install speedtest to compare
pip install speedtest-cli --break-system-packages
speedtest-cli
# Google Drive speed depends on server region.
# European servers typically reach 100-500 Mbps on Drive.
Common issues
"Too many requests" or slow download
Google Drive enforces rate limiting. Solutions:
# Add delay between files
rclone copy "gdrive:Folder" /root/ --transfers 4 --tpslimit 5
# Or use automatic backoff
rclone copy "gdrive:Folder" /root/ --retries 10 --low-level-retries 10
Downloaded file corrupted or HTML instead of file
# Verify the downloaded file is not an error HTML page
file filename.zip
head -c 200 filename.zip
# If shows HTML, the URL or ID is wrong, or the file is private
# Use gdown which handles these cases automatically
Private file (not publicly shared)
For non-public files, only rclone with OAuth authentication works. Cannot download them with curl or gdown without credentials.
Upload files to Google Drive from VPS
# Upload a file with rclone
rclone copy /root/backup.tar.gz "gdrive:Backup Server/" --progress
# Upload entire folder
rclone copy /var/backups/ "gdrive:VPS Backups/$(date +%Y-%m-%d)/" --progress
# Bidirectional sync
rclone sync /root/data/ "gdrive:Data/" --progress
Useful for automatic backups to Google Drive: see also Backup with Rclone.
Related articles
Server Reboot
How to properly restart your VPS or VDS, both via SSH and from the control panel
Resource Monitoring
How to check CPU, RAM, disk and network on your server in real time
Disk Management
How to check disk space, find large files and free up disk space
