Bali, Indonesia
Insights

Transferring Large Files Between Google Drive and Web Hosting Using Google Colab

October 30, 2026
0:00
Moving multi-gigabyte site backups, database dumps, or media archives between cloud storage and a web hosting server usually hits a bottleneck at your local internet connection. Downloading a 40 GB cpmove or .tar.gz archive to your laptop just to upload it back to Google Drive—or vice versa—burns hours of time and risks broken transfers if your connection drops. Because Google Colab provisions an ephemeral Linux container running on Google's datacenter network, you can mount your Google Drive directly to the container's filesystem and run standard Linux tools (cp, rsync, wget, curl, scp, gdown, and rclone) at gigabit speeds without routing a single byte through your local machine.
Every workflow starts by mounting your Google Drive to the Colab runtime.
  1. Open Google Colab (colab.research.google.com) and click New Notebook.
  2. Run the following Python cell to mount your Google Drive at /content/drive:
PYTHON
from google.colab import drive
drive.mount('/content/drive')
  1. Click Connect to Google Drive in the prompt, select your Google account, and grant access. Once mounted, your primary Drive contents live inside /content/drive/MyDrive.
Verify available disk space and your mounted directory structure by running a shell command (prefixed with !):
BASH
!df -h /content/drive/MyDrive
!ls -lah "/content/drive/MyDrive"
Google Drive does not let you directly transfer ownership of files across different Google Workspace domains or personal accounts when you only have Viewer access. Downloading and re-uploading manually is unnecessary—you can copy shared folders directly inside Colab using Drive shortcuts.
  1. On the Source Google Drive, right-click the file or folder you want to transfer, select Share, and grant at least Viewer access to your Destination Google Drive account.
  2. Log in to the Destination Google Drive, open Shared with me, right-click the shared folder or file, and click Organize -> Add shortcut.
  3. Select My Drive as the shortcut location.
Open Google Colab using your Destination Google Account, mount Drive as shown in Section 1, and verify how the shortcut appears in your filesystem:
BASH
!ls -la "/content/drive/MyDrive"
Important Note on Modern Google Drive Shortcuts: Depending on how the shortcut was created, Google Drive mounts folder shortcuts either directly under /content/drive/MyDrive/<Shortcut_Name> or resolves them inside the hidden /content/drive/.shortcut-targets-by-id/<Folder_ID>/<Folder_Name> path. Using rsync with -L (--copy-links) or cp -rL ensures symlinks are dereferenced and the actual files are copied rather than just the shortcut pointer.
Run rsync to copy the entire shared folder into a new real directory inside your destination Drive with live progress output:
BASH
!mkdir -p "/content/drive/MyDrive/Transferred_Backups"
!rsync -avhP --copy-links "/content/drive/MyDrive/Shared_Folder_Shortcut/" "/content/drive/MyDrive/Transferred_Backups/"
If you prefer standard cp:
BASH
!cp -rvL "/content/drive/MyDrive/Shared_Folder_Shortcut/." "/content/drive/MyDrive/Transferred_Backups/"
When migrating websites or archiving backups generated on a cPanel, Plesk, or bare-metal server, you can pull the file straight into your mounted Google Drive over HTTP/HTTPS or FTP without storing it on your PC.
Use %cd (Colab's magic command that persists directory changes across command lines in a cell) or pass the output directory directly to wget -P:
BASH
!mkdir -p "/content/drive/MyDrive/Server_Backups"
!wget -c "YOUR_DIRECT_BACKUP_URL/full-backup-2026-10-30.tar.gz" -P "/content/drive/MyDrive/Server_Backups/"
Useful wget flags for large hosting backups:
  • -c (--continue): Resumes a partially downloaded file if the connection resets.
  • -O "/content/drive/MyDrive/Server_Backups/custom-name.tar.gz": Saves the file under a specific filename.
  • --user=USERNAME --password='PASSWORD': Authenticates against HTTP Basic Auth or FTP endpoints.
If your hosting server limits single-thread bandwidth, install aria2 in the Colab runtime to pull the file over 16 parallel connections:
BASH
!apt-get update -qq && apt-get install -y -qq aria2
!aria2c -x 16 -s 16 -d "/content/drive/MyDrive/Server_Backups" -o "full-backup.tar.gz" "YOUR_DIRECT_BACKUP_URL/full-backup-2026-10-30.tar.gz"
Exposing a full server backup over a public HTTP URL is risky. A cleaner approach is pulling the backup directly over SSH from your hosting account or VPS into Google Drive.
Generate a temporary SSH keypair inside Colab, print the public key, and add it to ~/.ssh/authorized_keys (or cPanel -> SSH Access) on your hosting server:
BASH
!ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N "" -q
!cat /root/.ssh/id_ed25519.pub
Once the public key is added to your hosting server, pull the files directly into Google Drive using rsync over SSH (replace 22 if your hosting provider uses a custom SSH port like 2222 or 7822):
BASH
!rsync -avzP -e "ssh -p 22 -o StrictHostKeyChecking=no" username@your-server-hostname:/home/username/backups/ "/content/drive/MyDrive/Server_Backups/"
If you cannot add an SSH key quickly and need a one-off transfer using an SSH password:
BASH
!apt-get update -qq && apt-get install -y -qq sshpass
!sshpass -p 'YOUR_SSH_PASSWORD' rsync -avzP -e "ssh -p 22 -o StrictHostKeyChecking=no" username@your-server-hostname:/home/username/backups/site.tar.gz "/content/drive/MyDrive/Server_Backups/"
When restoring a site backup stored in Google Drive onto a new VPS or shared hosting server, you have two fast options: pushing the file from Colab to the server via SSH, or pulling the file directly from your hosting terminal using gdown or rclone.
With your Google Drive mounted in Colab and SSH access configured (Section 4), push the archive from /content/drive/MyDrive straight to your server's /home/username/ directory:
BASH
!rsync -avzP -e "ssh -p 22 -o StrictHostKeyChecking=no" "/content/drive/MyDrive/Server_Backups/full-backup.tar.gz" username@your-server-hostname:/home/username/
Or using scp:
BASH
!scp -P 22 -o StrictHostKeyChecking=no "/content/drive/MyDrive/Server_Backups/full-backup.tar.gz" username@your-server-hostname:/home/username/
If you have SSH access to your hosting server and want to download a shared file from Google Drive directly onto the server without opening Colab (wget often fails on large Google Drive files due to the virus-scan confirmation page), use gdown:
  1. Set the file permission in Google Drive to Anyone with the link (Viewer) and copy the File ID from the URL (drive.google.com/file/d/<FILE_ID>/view).
  2. Run the following on your hosting server via SSH:
BASH
pip3 install --user gdown
~/.local/bin/gdown --id YOUR_GOOGLE_DRIVE_FILE_ID -O backup.tar.gz
(Don't forget to revoke public link sharing in Google Drive once the download completes.)
Uploading thousands of small files (such as wp-content/uploads or node_modules) to Google Drive one by one is slow because Google Drive throttles high API request rates per second. Always compress folders into a single archive before moving them, or extract them on the Colab local SSD (/content) before pushing to a remote server.
BASH
!tar -czvf "/content/drive/MyDrive/Server_Backups/site-archive.tar.gz" -C "/content/drive/MyDrive/Raw_Site_Files" .
BASH
# Extract .tar.gz
!tar -xzvf "/content/drive/MyDrive/Server_Backups/site-archive.tar.gz" -C "/content/drive/MyDrive/Extracted_Site/"

# Extract .zip
!unzip -q "/content/drive/MyDrive/Server_Backups/site-archive.zip" -d "/content/drive/MyDrive/Extracted_Site/"
Google Colab writes to /content/drive through a FUSE filesystem layer that buffers writes in the background. If you transfer a 20 GB file and immediately terminate the Colab runtime, the file may not finish syncing to Google Drive. Always run drive.flush_and_unmount() at the end of your transfer session to guarantee every byte is committed to Google Drive's backend storage:
PYTHON
from google.colab import drive
drive.flush_and_unmount()
print("All pending transfers synced safely to Google Drive.")