TESTED GUIDE WITH UBUNTU 17.10 64-bit
You must first install and configure adb and fastboot for Linux.
Open the terminal (ctrl + alt + t) and write the following commands
sudo add-apt-repository ppa:phablet-team/tools
sudo apt-get update
sudo apt-get install android-tools-adb
sudo apt-get install android-tools-fastboot
1) download the zip file from HERE and place it on the desk;
2) Restart the device in fastboot mode and connect it to the computer with USB cable;
3) on UBUNTU unpack the .zip by right-clicking on the file and selecting "extract here", now open the newly created folder and unpack the .tar file that you will find in it;
More generally, to extract .zip and .tar files from the terminal, you use the commands:
tar -xvf nomefile.tar
in our case, from desk, give the following commands:
tar -xvf Xiaomi_MiFlash_new.tar
5) To start the program, open a new terminal window (ctrl+alt+t) and type the following commands:
cd XIAOMI-TOOL-MiFlash-for-Linux-by-IceMan-master/Xiaomi_MiFlash_new && ./go.sh
6) copy the rom .tgz file to / XIAOMI-TOOL-MiFlash-for-Linux-by-IceMan-master / Xiaomi_MiFlash_new / XIAOMI-FILE folder
7) Select "1" for firmware flash
8) Select "1" to choose the rom file to install
9) Select one of the flash options and wait for the operation to complete:
BACKUP ROM FORMAT .TGZ
1) Start the phone in TWRP and connect it to the PC.
2) start the tool as in step 5 above and select option "2".
BACKUP ONLY WORK WITH TERMINALS WITH MARSHMALLOW OR SUPERIOR ANDROID VERSION.
credits: Iceman-IT (developer)