1. Home
  2. Linux
  3. Back up telegram settings on linux

How to back up your Telegram settings on Linux

Are you looking to back up your Telegram user information and settings on your Linux PC? Not sure about how to do it? We can help! Here’s how to back up your Telegram settings on Linux!

Before we begin

There are many different ways of installing Telegram on the Linux desktop. Users can install the app from the Ubuntu Snap Store, by downloading the Telegram binary from the website, installing as a Flatpak, or by installing the Linux “telegram-desktop” package from many mainstream distribution software sources.

All of these installation methods save your Telegram login information differently. In this guide, we will focus solely on backing up Telegram settings for the “telegram-desktop” package for Linux, and not the Snap, Flatpak, or downloadable binary release of Telegram. If you need to back up your settings for the Snap, Flatpak, or the downloadable binary release, refer to your Linux operating system’s official wiki or online support system instead.

Creating a backup with Tar

The Linux Telegram application saves all of its user data in a strange place. Unlike other programs, you won’t find your Telegram app settings in the ~/.config folder. Instead, all of the Telegram user data is located in the ~/.local/share/TelegramDesktop/ directory.

To start the backing up process, you must open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, once the terminal window is open, use the CD command to move the terminal session into the ~/.local/share/ directory.

cd ~/.local/share/

Once inside of the ~/.local/share/ directory, make use of the ls command and view the contents of the directory. Assuming you’ve used the Linux release of Telegram, you’ll see the TelegramDesktop folder appear in the terminal prompt.

ls

Having issues locating the TelegramDesktop folder using the ls command? Try running the ls command along with grep. It can filter out specific keywords and makes it much more manageable.

ls | grep TelegramDesktop

If the TelegramDesktop directory appears in the terminal prompt, make use of the following tar command below. It will take the TelegramDesktop directory and compress it to a TarGZ archive. Placing the TelegramDesktop folder inside of a TarGZ archive ensures that your settings are easily transferable over the internet or via LAN file-sharing tools.

tar -czvf My-Telegram-Desktop-Backup.tar.gz TelegramDesktop

When the tar command finishes, all of your Telegram settings will be saved in the My-Telegram-Desktop-Backup.tar.gz file. From here, use the mv command to move the My-Telegram-Desktop-Backup.tar.gz file from the ~/.local/share/ directory to your home folder (~).

mv My-Telegram-Desktop-Backup.tar.gz ~/

cd ~/

With the My-Telegram-Desktop-Backup.tar.gz file in your home directory, feel free to take it and put it on Dropbox, Google Drive, a home server, or an external USB flash drive or USB hard drive. But be warned that it is unencrypted, and anyone can gain access to your Telegram settings.

Encrypting the backup

It is a good idea to encrypt your Telegram settings backup. Without encryption, your settings are vulnerable to tampering if they fall into the wrong hands. To encrypt your Telegram settings, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, follow the step-by-step instructions outlined below.

Step 1: Check and see if you have the GPG tool installed on your Linux PC by running the gpg --help command. If it is installed, you will see the GPG help prompt appear. If nothing happens, you will need to install it.

gpg --help

Step 2: Using the gpg command, encrypt your Telegram backup.

gpg -c My-Telegram-Desktop-Backup.tar.gz

Step 3: Delete the unencrypted backup from the system using the rm command.

rm My-Telegram-Desktop-Backup.tar.gz

When you’ve deleted the unencrypted backup, you will be left with My-Telegram-Desktop-Backup.tar.gz.gpg, the encrypted version of your backup. Copy it to Dropbox, Google Drive, etc. for safe-keeping.

Restoring the backup

Need to restore your Telegram settings? Copy the encrypted backup My-Telegram-Desktop-Backup.tar.gz.gpg to your home directory (~). Then, follow the step-by-step instructions below to restore the backup.

Step 1: Decrypt the backup with the following gpg command.

gpg My-Telegram-Desktop-Backup.tar.gz.gpg

Step 2: Use the tar command to extract the contents of the decrypted backup file to the ~/.local/share/ directory.

tar xvf My-Telegram-Desktop-Backup.tar.gz -C ~/.local/share/

Step 3: Delete the unencrypted backup from your home directory now that the contents of it are in the ~/.local/share/ directory, and you have no use for it.

My-Telegram-Desktop-Backup.tar.gz

Step 4: Re-open up Telegram on your Linux desktop. When the app is open, your settings should be exactly the way they were when you created the backup.