LinuxCommandLibrary

timeshift

Restore system to a previous state

TLDR

List snapshots

$ sudo timeshift --list
copy

Create a new snapshot (if scheduled)
$ sudo timeshift --check
copy

Create a new snapshot (even if not scheduled)
$ sudo timeshift --create
copy

Restore a snapshot (selecting which snapshot to restore interactively)
$ sudo timeshift --restore
copy

Restore a specific snapshot
$ sudo timeshift --restore --snapshot '[snapshot]'
copy

Delete a specific snapshot
$ sudo timeshift --delete --snapshot '[snapshot]'
copy

SYNOPSIS

timeshift [OPTIONS] [COMMAND]

Common Commands:
timeshift create [--comments "text"] [--tags daily|hourly|weekly|monthly|boot|manual]
Creates a new snapshot.

timeshift restore [--snapshot N] [--target /path/to/restore]
Restores the system to a specified snapshot.

timeshift delete [--all] [--snapshot N] [--tags tag]
Deletes existing snapshots.

timeshift list
Lists all available snapshots.

timeshift gui
Launches the graphical user interface.

timeshift --check
Performs a system check and setup.

PARAMETERS

-h, --help
    Displays the help message and exits.

-v, --version
    Displays version information and exits.

--check
    Performs a system check and initial setup, including device and configuration checks.

--snapshot N
    Specifies the index number N of the snapshot to perform an operation on (e.g., restore, delete). The index is shown by timeshift list.

--comments "text"
    Adds a descriptive comment to the snapshot being created.

--tags tag
    Assigns tags (e.g., daily, hourly, weekly, monthly, boot, manual) to the snapshot for better organization and automation.

--delete-all
    Used with the delete command to remove all existing snapshots.

-y, --yes
    Assumes 'yes' to all prompts, allowing non-interactive operation.

--target /path
    Specifies an alternative target directory for restore operations, useful for offline restores.

--force
    Forces an operation, bypassing some safety checks (use with caution).

DESCRIPTION

Timeshift is an essential system restore utility for Linux, providing a robust solution for protecting your operating system.
It functions by creating incremental snapshots of your file system, which can be used to restore your system to a previous working state in the event of software issues, failed updates, or accidental changes.
Two primary snapshot modes are supported:
1. Rsync Mode: This mode uses rsync and hard links to create snapshots, making it compatible with most Linux file systems. It effectively saves disk space by only storing new or modified files.
2. Btrfs Mode: For systems running on a Btrfs file system, this mode leverages native Btrfs features to create efficient snapshots.
By default, Timeshift focuses on system files and configurations (e.g., /, /boot, /etc), excluding user data (e.g., /home, /root) to keep snapshots lean and restoration processes quick. This design ensures that a system can be swiftly reverted to a stable condition without affecting personal files. Both a command-line interface and a graphical user interface are available, catering to different user preferences.

CAVEATS

Key Limitations and Considerations:
1. User Data Exclusion: By default, Timeshift excludes user home directories (e.g., /home/username). This is intentional to keep snapshots small and system restores fast. Users must manually configure inclusions if they wish to snapshot specific user data.
2. Disk Space Consumption: Snapshots can consume significant disk space, especially if frequent or large system changes occur. Regular review and deletion of older snapshots are recommended.
3. Btrfs-specific Requirements: Btrfs mode only works if your root (/) filesystem is formatted as Btrfs. Rsync mode is more universally compatible.
4. Not a Full Backup Solution: Timeshift is primarily a system restore utility, not a comprehensive backup solution for all your data. It does not protect against hardware failures or loss of your entire disk.
5. Live Environment for Restore: For a successful system restore, especially if the system is unbootable, it often requires booting into a live Linux environment (e.g., from a USB stick) to run Timeshift.

HOW SNAPSHOTS WORK

Timeshift creates snapshots efficiently. In Rsync mode, it uses hard links for unchanged files between snapshots, meaning only new or modified files consume additional space. This makes incremental snapshots very space-efficient. In Btrfs mode, it leverages native Btrfs subvolume features, which are inherently copy-on-write, making snapshots virtually instant and highly efficient in terms of space.

RESTORE PROCESS OVERVIEW

When you initiate a restore with Timeshift, it attempts to revert your system files and configurations to the state captured in the selected snapshot. If the system is currently running, Timeshift will often prompt for a reboot into a chroot environment or a live USB session to safely perform the file replacement, ensuring critical system files are not in use during the process. It handles updating the bootloader (GRUB) and generating initramfs images automatically to ensure the restored system is bootable.

CONFIGURATION AND AUTOMATION

Timeshift allows users to configure automated snapshot schedules (e.g., hourly, daily, weekly) and retention policies (how many snapshots to keep). These settings can be managed via both the GUI and command-line. Users can also specify custom include/exclude filters to tailor what data is included or excluded from snapshots beyond the defaults.

HISTORY

Timeshift was developed by Tony George and first released to the public around 2017. It quickly gained popularity among Linux users looking for a reliable and user-friendly system restore utility, akin to features found in Windows (System Restore) and macOS (Time Machine). Its design philosophy focused on simplicity and effectiveness for system rollbacks, distinguishing it from general-purpose backup tools. Its integration with popular distributions, notably Linux Mint and Ubuntu-based systems, further cemented its role as a standard tool for system stability and recovery.

SEE ALSO

rsync(1), btrfs(8), snapper(8), grub(8), deja-dup(1), apt(8), dnf(8)

Copied to clipboard