• This repository has been archived on 28/Apr/2020
  • Stars
    star
    447
  • Rank 97,700 (Top 2 %)
  • Language
    Kotlin
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java app to download all your telegram data.

Telegram_Backup

Copyright 2016 Fabian Schlenz
Licensed under GPLv3

State of this project

The tool is working, but not really as intended: Media files in most cases can't be downloaded, message downloads are hit with 30 second delays after every 200 messages. Some users reported getting banned by Telegram without reason after using this tool (with many users not getting banned at the same time, so this could theoretically just be a coincidence).

At the same time, the official Telegram client has an official way to download one's data, which is a) officially supported and b) much, much, much faster than this tool.

Fixing this tool to at least get it to work again as planned would require more or less a complete rewrite of this code. Since I'm quite happy with the possibilities given by the official clients and don't have enough free time to spare to continue developing this project, I've decided to officially archive this tool. This is not an easy step for me, because this was my most used project and quite a lot of people wrote me nice messages and thanked me. But just keeping the user's hopes up for an update without really being able to do something doesn't seem fair. So...

So long, and thanks for all the fish. ;-)
Fabian

Description

This is a small Java app that allows you to download all your history from Telegram's servers and keep a local copy of them.

Download

You can find the whole app packed into one fat jar file under releases.

Features

  • You can use multiple accounts with this tool.
  • Messages are saved in a SQLite database; media (documents, photos, videos, stickers, geolocations, audios) are downloaded and saved as files.
  • A GUI is planned for later; at the moment this is a command line tool only.
  • Incremental backups - if you run the tool at a later time, it will only download new messages / media.

Limitations

This tool relies on Telegram's API. They started rate limiting the calls made by this tool some time ago. As of February 2017, downloading messages is limited to 400 messages every 30 seconds, resulting in 48,000 messages per hour. Media download is not throttled right now, so it should be a lot quicker.

But since this tool is designed to be able to continue it's work at any time, you can just abort the download and continue it later - that way, you'll be moving step by step towards a complete archive of your telegram messages and media files.

Usage

You need to have at least Java 1.7 installed on your machine. Download the jar file, and run it on the console like this: java -jar telegram_backup.jar.

Append --help to get a list of all available commands.

Basically, you have to call it with --login first to login to your telegram account and then call it again with --account <phone> to use this account and download all it's history. If you have just one account, you can omit this parameter.

Use --with-supergroups and / or --with-channels to also download all messages from the supergroups / channels you have joined that have been active in the last time.

After making a backup, call it again with --export html to create a few more-or-less nice to look at HTML files containing all your chats. They will be created in the subfolder files of your backup. You can just open the file index.html in your browser to look at the files.

Donations

I've put quite some time into this tool. If you want to donate a small amount, you can send it via Bitcoin to 1CofYzS88iEngxMu4NqQeohWDBUHv9CNDJ or via PayPal to [email protected].

Alternatively use this link the next time you shop at amazon.com or this link for amazon.de. You won't pay any more, but I will get a few percent of your purchase's worth from amazon.

Contact

If you have questions or comments or need help, you can join the telegram_backup Development group at Telegram.

Frequently asked questions

Why do I see error messages?

The library I'm using to access Telegram has some small bugs. One of those is the display of meaningless (because they are being acted accordingly upon) error messages. Those include:

  • Exception in thread "pool-x-thread-y" java.lang.Error: java.nio.channels.ClosedChannelException
  • Something containing AUTH_ERROR You can just ignore these messages.

Basically, if the tool is continuing to run after error messages are shown, you can just ignore the messages. Either way, even if Telegram_Backup would "miss" some files or messages, this will be detected at the next run of this program and then tried again.

Where do you save the files?

The files are being saved in your User directory in a folder named telegram_backup. Under windows, this would typically be under C:\Users\<username>\telegram_backup. Linux users should look unter /home/<username>/.telegram_backup.

You can change this directory by supplying --target <dir> when calling Telegram_Backup.

What are those files and folders?

In the folder telegram_backup is one folder named stickers, which will hold all sticker images you've received. Then there is a folder for each account, named after the phone number associated with that account.

In these folders you will find auth.dat and dc.dat, which contain authentication data. There is database.sqlite which is a SQLite3 database containing all your messages and other data. The folder files contains all media files, named after the ID of the message they belong to. Last but not least the folder export contains exported data.

What are EmptyMessages? Why are there so many messages?

If you are a member of a normal group (non-supergroup), all messages sent to that group are being copied to your personal messages at Telegram's servers.

If you later leave this group, those messages are being deleted at Telegram, but since all messages are continuously numbered, you can't simply delete them because that would leave a hole in your message numbers. So these messages are instead replaced by EmptyMessages - those things contain zero information, they are just saying "here was a message but it was deleted".

Attribution

This tool uses libraries from other developers which are covered by other licenses, which are:

  • Kotlogram by Yannick Badoual, licensed under MIT License.
  • SQLite JDBC by Taro L. Saito, licensed under Apache License version 2.0.
  • Mustache.java by RightTime, Inc., licensed under Apache License version 2.0.
  • Logback by QOS.ch, licensed unter LGPL version 2.1.
  • SLF4J by QOS.ch, licensed under MIT license.

More Repositories

1

telegram.sh

Send telegram messages right from your command line.
Shell
477
star
2

OctoPrint-Telegram

Plugin for octoprint to send status messages and receive commands via Telegram messenger.
Python
311
star
3

matrix.sh

Send messages via matrix chat protocol right from your command line
Shell
114
star
4

geotweeter

The geotweeter is a Twitter client written entirely in coffeescript. Discontinued since Twitter decided that third-party clients are "evil".
CoffeeScript
6
star
5

sinatra_wms

Rubygem to make developing a Web Map Service in Sinatra really easy.
Ruby
5
star
6

sneaker_bot

A simple Twitter bot written in Ruby to manage participations in visiting sneak previews
Ruby
4
star
7

twirror.rb

A simple Twitter-Feed-Backup-Tool.
JavaScript
4
star
8

telegram_backup_browser

Browser based backup of telegram data. Deprecated. See telegram_backup for a pure Java implementation.
JavaScript
4
star
9

environment

My working environment (bashrc, vimrc, screenrc, ...)
Vim Script
3
star
10

fabianonline.de

Ruby
3
star
11

telegram_archival_bot

Ruby
3
star
12

ws300

A small "driver" for weatherstations "WS300", written in Python
Python
3
star
13

wii2osc.py

Python script to "convert" Wiimote inputs to OSC signals
Python
2
star
14

simple_jabber

Very simple Script to send messages via Jabber
Ruby
2
star
15

geoloqi-backup

Ruby
1
star
16

serverlogs

1
star
17

rubycom

Webcomic download system written in RoR
Ruby
1
star
18

ampel

Java-based game in which the user has to control traffic lights
Java
1
star
19

ksp-rockets

1
star
20

pizza

Simple Pizza Ordering System written with Sinatra
Ruby
1
star
21

refugees-picture-dictionary

1
star
22

sweet_light

Java
1
star
23

processing-kld7

Processing
1
star
24

docker-commands

Some useful bash aliases for use with docker
Shell
1
star
25

offline-subway

1
star
26

geotweeter-for-android

Collaborative project to rebuild the geotweeter as android app. Discontinued since Twitter decided that third-party clients are "evil".
Java
1
star
27

cacti-scripts

PHP
1
star