Save Ubuntu in a Snap with Timeshift: A Guide to Creating Automatic Restore Points

Ubuntu tutorial - IT technology blog
Ubuntu tutorial - IT technology blog

Just ran a command and… it’s gone

If you’ve used Ubuntu long enough, you’ve likely faced this: You just ran sudo apt upgrade, rebooted, and now the machine is stuck at the logo or showing a black screen. Sometimes, just trying to install the latest NVIDIA 550 driver or experimenting with a “strange” PPA causes the system to lag uncontrollably or lose network connectivity altogether.

At this point, reinstalling the OS is the last resort. You’ll spend hours setting up Docker, configuring Nginx, tweaking .zshrc, or reinstalling GNOME extensions. For IT professionals, this is a total nightmare in terms of time management.

3 Reasons Why Ubuntu Systems Break

To be fair, Ubuntu is quite resilient. However, the system can still collapse due to these three common reasons:

  • Driver Conflicts: Most common with graphics cards or incompatible kernel modules after an update.
  • PPA Clutter: Adding too many third-party repositories can lead to version conflicts and overwrite critical system libraries.
  • Human Error: A misplaced rm -rf command or editing a config file in /etc without a backup can break the entire OS.

In my staging environment, before changing the kernel on an Ubuntu 22.04 server, I always prepare a safe “fallback plan.” That is why Timeshift has become an indispensable tool.

Why Not Use Traditional Backup Methods?

Before sticking with Timeshift, I tried several methods, but they all had drawbacks:

  1. Manual Compression: Bundling the entire root directory into a .tar.gz file is extremely slow and consumes too much space.
  2. Using the dd Command: Cloning the entire hard drive is only suitable when replacing drives. It’s incredibly inconvenient for daily use.
  3. Manual Rsync: You need to be an expert in system file structures to know which directories to exclude, like /proc, /sys, or /dev; otherwise, the backup will be corrupted.

Timeshift: The “Time Machine” for Linux

Timeshift works similarly to System Restore on Windows. It focuses on protecting system files and settings rather than personal data (like photos or videos). As a result, backups are fast and don’t consume excessive storage.

How to Install Timeshift on Ubuntu

While it is available in the default Ubuntu 22.04/24.04 repositories, you should use the official PPA to get the latest bug fixes:

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

Should You Choose RSYNC or BTRFS?

When you launch it for the first time, the software will ask you to choose a mode:

  • RSYNC: The universal mode that runs on any partition format (EXT4, XFS, etc.). It performs a full backup the first time, but subsequent backups only copy changes (using hard links). This method is both fast and space-efficient.
  • BTRFS: Only use this if your drive was formatted as BTRFS during installation. It leverages the file system’s snapshot feature, making restoration take only a few seconds.

Advice: If you are using a default Ubuntu installation, stick with RSYNC for reliability.

Backup Schedule Setup (Best Practices)

Don’t wait until your system breaks to regret it. Go to the Schedule tab and use this “golden” formula to optimize disk space (usually only taking about 20-30GB per week):

  • Monthly: Keep 1 snapshot.
  • Weekly: Keep 2 snapshots.
  • Daily: Keep 5 snapshots.
  • Boot: Keep 1 snapshot (to protect against errors immediately after startup).

Timeshift will automatically delete the oldest snapshots, so you don’t have to worry about your disk filling up.

A Note on Personal Data

By default, Timeshift excludes the /home/user directory. This is great: when you rollback the system to 2 days ago, your newly written code files or recently downloaded documents are not lost. If you want to keep customizations like .zshrc, go to the Users section and select “Include Hidden.”

How to Rescue Your System When Trouble Strikes

Case 1: You Can Still Access the Desktop

If the system only has minor glitches, open Timeshift, select the most recent snapshot, and click Restore. After the machine reboots, everything will return to its perfect state.

Case 2: Total System Crash (Black Screen)

This is where Timeshift truly shines. You will need an Ubuntu Live USB:

  1. Boot into Ubuntu from the USB (select Try Ubuntu).
  2. Install Timeshift directly within the Live USB environment.
  3. Open the app; it will automatically scan and find the snapshots on your computer’s hard drive.
  4. Click Restore and leave the Bootloader options as default.

After about 5-10 minutes, unplug the USB and reboot; your machine will miraculously “come back to life.”

Practical Tips from the Field

Before running a major update script or changing Nginx configurations on a server, I usually run this quick command:

sudo timeshift --create --comments "Before editing Nginx" --tags D

This command creates a manual restore point immediately without opening the GUI. If something goes wrong, I only lose a few minutes rolling back instead of troubleshooting all night.

Final Note: Timeshift is not a tool for backing up photos or videos. To protect personal data, you should use Rclone or Google Drive. Think of Timeshift as “insurance” for the health of your operating system only!

Share: