Backup your Telegram files automatically, like a boss.
I used Telegram as my personal cloud for years β stuffed it with images, music, memes, GIFsβ¦ and suddenly: π 3,000+ files and counting.
At that point, finding anything in Telegram was like:
search β scroll β scroll β scroll β rage quit
So I decided to rescue my files and move them to Google Drive, where they can actually be searched, sorted, and found in seconds.
This script: β Downloads your Telegram images, music, GIFs (skips text & MP4s) β Uploads them straight to Google Drive β Can resume where it left off if your internet dies π β Lets you skip a file mid-download/upload if you donβt want it β Can do parallel downloads & uploads so itβs not slooooow β Saves your sanity π§ β¨
- Auto-resume β restarts from last successful upload
- Skip command β type
sduring download/upload to skip the current file - Retry logic β failed files will retry up to 3 times before being skipped
- Timeout handling β skips files that donβt start downloading after 10 min
- Selective backup β only grabs images, music, GIFs (no MP4s, no random text files)
- Parallel transfers β downloads & uploads multiple files at once for speed
- Python 3.8+
- A Telegram API key β Get it here
- A Google Drive API client secret β Follow this guide
- Internet that doesnβt cry halfway through π
# Clone the repo
git clone https://github.com/akshay-k-a-dev/telegram-to-gdrive-pipeline.git
cd telegram-to-gdrive-pipeline
# Install dependencies
pip install -r requirements.txt1οΈβ£ Put your Telegram API ID & API Hash in the config section of the script. 2οΈβ£ Download your Google Drive client_secrets.json and save it somewhere safe. 3οΈβ£ Update the script with your Google Drive folder ID.
python backup.py- Script will ask you to log into Telegram on first run.
- It will also open a browser window for Google Drive authentication.
- Sit back, relax, and let it work. β
π‘ While itβs running:
- Type
sβ skip the current file and move to the next one.
- uploaded_files.log β Keeps track of files already uploaded.
- failed_downloads.log β Files that failed after retries.
- Add support for MP4 video backup (optional)
- Add filtering by file size
- Make it run as a scheduled background service
This project started as a "Iβll just move a few files" thingβ¦ And turned into a "Holy crap my Telegram is a warehouse" mission.
Now my files live happily in Google Drive, and I donβt have to scroll endlessly anymore.
π’ + β‘ = β€οΈ