How To Backup And Restore Ubuntu Using Timeshift?


Gaming Laptop Series

A system backup is a process in which the state, files, and data of a computer system are copied and stored somewhere. Later if primary data is corrupted, deleted, or lost then it is used to recover the original data.

For useful recovery, a backup must be made by copying the source data image when it is in a consistent state. In this article, we will discuss backing up and restoring a system using the timeshift tool. This method applies to Ubuntu and distributions based on it such as Linux Mint, Kubuntu, etc.

Unlike the tar method of backup and restore which only deals with the files, this method brings back the system to the backup snapshot state and not just the files.

What are Snapshots?

A traditional way of backing up creates copies of data while the snapshots are an instantaneous picture of your filesystem at a certain period of time. When this snapshot is used to restore the system. The system reverts back as it was at the time of taking the snapshot. Snapshots are usually good if you want to revert to a recent version of your system. This is faster than the traditional way of backing up the system.

What is the timeshift tool?

So before we discuss what timeshift tool does, you should know about the incremental backup. An incremental backup is an advanced type of backup technique. In which only the data created or modified since the last backup has taken, is backed up. It saves disk space as well as reduces the time taken in the backup process. Now the timeshift is an application that protects your system by taking incremental snapshots of the file system at regular intervals. Timeshift is designed to protect only system files and settings. These snapshots can be restored at a later date to undo all changes to the system. A snapshot can be created in two modes –

RSYNC mode – It comparatively takes more time but can be taken for any filesystem.

BTRFS mode- These snapshots are supported only on the BTRFS systems. It takes very little time to create a snapshot.

Installing Timeshift

To install timeshift in Ubuntu or a distribution based on it, first, you need to add a repository by using –

sudo add-apt-repository -y ppa:teejee2008/timeshift

Now update apt’s package index with –

sudo apt-get update

Install timeshift by using –

sudo apt-get install timeshift

Preparing USB drive for backup

It is the best practice to save the snapshots on a separate disk. We will use a USB drive of 32 GB of space. The USB drive that you are going to use should be formated in the ext3/ext4 filesystem. Now to format the USB drive in ext4 filesystem open your terminal and execute the following commands –

To display the all disks and partition on your system use –

lsblk

Now unmount /dev/sdb1 with –

sudo umount /dev/sdb1

And then format it with ext4 filesystem by using-

sudo mkfs.ext4 /dev/sdb1

Creating Backup

First, open timeshift application from the menu. If you click on it you will ask to enter the password, enter it. The UI of application will look something like this-

Before you start creating snapshots make a few changes in its settings. Click on the settings as given below –

Under the Type tab, you can select the type of snapshot you want to create. By default it uses RSYNC, leave it as it is.

Next click on the Location. And select the USB drive where this snapshot will store. Look at the image below-

In the Schedule tab, you can define the snapshot levels. Choose among month, weekly, daily hourly, or boot here you can select the multiple options. You can also mention the number of snapshots to take.

Similarly, you can click on the Users tab to enable the user data to backup. And in the Filters tab, you can specify a pattern for users to take backup. Once you are done making changes press OK. Now to create snapshot click on the create it will start creating backup like this –

It will take some time to create a snapshot of your system. And once completed you will see like this –

Restoring from backup

Now if you are login into your system and want to restore your system to a previous state. Then select a snapshot and click on restore. The next screen would be to select the target to restore.

You can also see the bootloader options by clicking on Bootloader Options(Advanced). Here you can choose the options like reinstall the GRUB2, update the Grub menu, etc.

Now press the Next. This will start comparing files.

Once it gets done comparing files. You will ask to confirm the actions. Look in the image below –

If you press Next the restore process will start and It can restart your system. Now once the process complete that means the restore process has done.

Now suppose you are not able to open your system’s GUI or the system is damaged beyond repair. What will you do in this situation? To restore your system in this situation you need to have a Ubuntu or Linux Mint live USB. Boot into the live session and install the timeshift on it. Now open timeshift and select the location where the backup is saved. And then follow the instructions to restore as given above. You can get more information about timeshift here.

1 thought on “How To Backup And Restore Ubuntu Using Timeshift?”

  1. I have several “snapshots” on a USB drive, but Timeshift shows no snapshots available. When I browse, I see folders and files of the backups. Any idea what’s up with that?

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.