Timeshift: Your Linux System's Best Friend for Backup and Restore

Hey everyone, ever had your Linux system go belly up? It’s a pain, right? But what if you could rewind time and get back to a working state? That’s where Timeshift comes in! This utility lets you back up your system settings and files, making it a lifesaver when things go south. It creates snapshots of your system at intervals you define, which you can then use to restore your system. It might be pre-installed on some distros, but here’s how to get it if you don’t have it.

Installing Timeshift on different Linux distros

  1. Ubuntu and Debian-based distros: If you’re on Ubuntu, Linux Mint (if it’s not already there), or any Debian-based system, just pop open your terminal and type:

    sudo apt install timeshift
    
  2. Arch Linux and Arch-based distros: For you Arch users (or Manjaro, etc.), make sure you’ve got AUR enabled, then fire up your terminal and run:

    yay -S timeshift
    
  3. Fedora and Red Hat-based distros: On Fedora and its relatives, use the following command in your terminal:

    sudo dnf install timeshift
    

Important Considerations:

Keep in mind that Timeshift skips your /home directory by default. This is because your user files aren’t meant to be part of a system restore. Think documents, pictures, and so on. For those, you’ll want a separate backup solution. Also, Timeshift is really designed for desktop systems, not servers. If you’re running a server, look into other backup tools that are more appropriate.

Using Timeshift to backup your Linux system

  1. Alright, now that you’ve got Timeshift installed, launch it! You’ll probably need to enter your password.

  2. Next up, you have to choose the snapshot type. You’ve got two main options: RSync and BTRFS.

    • RSync: This method works by creating snapshots that share common files between different backup periods. Each snapshot is a full backup, so you can browse it with a file manager. If you’re using the typical EXT4 filesystem, RSync is the way to go.
    • BTRFS: This creates snapshots using the BTRFS filesystem. It’s designed for systems that use a subvolume layout, like Ubuntu with BTRFS.
  3. Now, where do you want to save your snapshots? You can use your system’s internal drive or an external one. If you’re using an internal drive, you can set up automatic scheduled backups. With an external drive, you’ll need to manually kick off the backups.

    Important: Using an external drive is a great idea to ensure you have a backup even if your whole system goes down. Just make sure that it’s formatted with a Linux filesystem like EXT4.

  4. Next up, schedule those backups! Timeshift lets you schedule backups hourly, daily, weekly, or monthly. You can pick one or more, and even set how many backups to keep for each schedule. Just remember to make sure that you’ve got enough free storage space for all those backups!

  5. Time to choose what to back up. As I mentioned earlier, your user files are skipped by default, but you can include hidden files and folders if you want. This will also back up your configuration files. Be aware that restoring these might overwrite your current configurations with older versions.

  6. After setting up Timeshift, you can click “Finish” or just close the window.

  7. You’re now on the Timeshift main screen. Just hit “Create” to make your first backup! Then, just wait for the process to wrap up.

  8. Want to get super specific about what’s backed up? In the main Timeshift window, click “Settings.”

  9. Click on the ‘Filters’ tab at the top and then on ‘Add Files’ or ‘Add Folders’ as per your requirements.

  10. To include your files and folders in the backup, click on the button next to them so it moves toward the ‘+’ icon before clicking on OK.

    Tip: See that “Summary” button? Give it a click! It’ll show you a list of everything that’s going to be included in the backup, marked with a “+” icon.

Restoring your Linux file system from a backup

Okay, you’ve made a backup (or several). Now disaster strikes! How do you restore from that backup?

  1. Restoring from within your Linux system: If you can still log in, just launch Timeshift from the menu. Make sure your external drive is plugged in if your backups are stored there and then click on ‘Restore’.

  2. Restoring from a live USB: What if you can’t even log in? No sweat! Here’s how to restore using a live Linux USB:

    1. Boot up from your live Linux USB.

    2. Open a terminal and type:

      sudo add-apt-repository universe
      

      Then press Enter.

    3. Next, install Timeshift:

      sudo apt install timeshift
      

      Once it’s done installing, launch the program.

    4. Click “Next” and select the drive where your backup is stored. It should then show up in the main Timeshift window.

    5. Click ‘Restore’ as before and provide the path where you want to restore the backup. Reinstalling the bootloader while restoring can make things easier for you.

    6. Click “Next.” Timeshift will do a “Dry Run” first.

    7. Confirm the actions Timeshift will take.

    8. Timeshift will warn you that data will be formatted if you proceed. Click Next to proceed and the process will begin. Reboot your computer once the process is complete.

Some things to keep in mind

  • Timeshift also lets you back up files with specific extensions. This can be done by adding those extensions and creating a list of such files.
  • The more backups you keep, the more space you will need. If you’re making hourly or daily backups, your storage will fill up faster.
  • If you prefer using command line, Timeshift supports this as well.
  • Timeshift works on all Linux distributions, so it shouldn’t be too confusing even if you switch to a different distro.