Timeshift Documentation

repository·master·Indexed 26 days ago

https://github.com/linuxmint/timeshift

A system restore utility for Linux that provides incremental snapshots of system files and settings. Supports RSYNC and BTRFS snapshot modes, configurable snapshot schedules (Hourly, Daily, Weekly, Monthly, Boot, and On-demand), and both online and offline restoration methods. Designed to protect system state while excluding user data by default.

Tokens
1.9K
Snippets
5
Records
14
Agent score
38%

What's inside Timeshift

  1. Install Timeshift on various distributions

    master

    Install Timeshift using your distribution's package manager. Note that Fedora is not fully supported, and BTRFS snapshots specifically require Ubuntu-style layouts.

    # Debian-based (Debian, Ubuntu, Linux Mint, Elementary OS, etc.)
    sudo apt-get update
    sudo apt-get install timeshift
    
    # Fedora
    sudo dnf update
    sudo dnf install timeshift
    
    # Arch
    sudo pacman -S timeshift
    
    # ALT
    su -
    apt-get update
    apt-get install timeshift
  2. Restore the system from a snapshot

    master

    You can restore your system using two methods:

    1. Online Restore: Restoring from within the running system. This requires a reboot to complete the process.
    2. Offline Restore: Restoring from another system that has Timeshift installed. This is useful if the main system is unbootable. You can boot from an Ubuntu Live CD, install Timeshift on the live environment, and then perform the restore.

    Cross-Distribution Restore: You can use Timeshift to revert to a previous distribution (e.g., moving from Linux Mint back to Xubuntu) by restoring a snapshot saved on a separate Linux partition. This requires that your snapshots are stored on a non-system partition, as installing a new distribution typically formats the root partition.

  3. Install development dependencies for Timeshift

    master

    To build Timeshift from source, you must install several development libraries and build tools. On Debian-based distributions, you can install all required dependencies using apt.

    sudo apt install meson \
    help2man \
    gettext \
    valac \
    libvte-2.91-dev \
    libgee-0.8-dev \
    libjson-glib-dev \
    libxapp-dev
  4. Restore snapshots on EFI and GRUB2 systems

    master

    When restoring snapshots, adhere to these requirements to ensure a bootable system:

    • Bootloader: Only systems using the GRUB2 bootloader are supported. Using older versions of GRUB may result in a non-bootable system.
    • EFI Partition: EFI systems are supported. Ensure the */boot/efi partition is mapped during restoration (Timeshift attempts to map this automatically if detected).
    • Live Media Restoration: If you are restoring a system from a Live CD/USB and the target system uses EFI mode, you must boot the Live CD/USB in EFI mode.
  5. Build and install Timeshift from source

    master

    Follow these steps to clone, build, and install the Timeshift repository using the Meson build system:

    1. Clone the repository from GitHub.
    2. Navigate into the project directory.
    3. Initialize the build directory using meson setup.
    4. Compile the project using meson compile.
    5. Install the binaries to your system using meson install.
    git clone git@github.com:linuxmint/timeshift.git
    cd timeshift
    meson setup build
    meson compile -C build
    sudo meson install -C build
  6. Uninstall Timeshift and clean up snapshots

    master

    Before uninstalling Timeshift, you must delete all existing snapshots to prevent them from continuing to occupy disk space.

    1. Open the Timeshift application.
    2. Select all snapshots (use CTRL+A).
    3. Click the Delete button on the toolbar.
    4. Once snapshots are removed, uninstall using your package manager:
    # Debian/Ubuntu
    sudo apt-get remove timeshift
    
    # Fedora
    sudo dnf remove timeshift
    
    # Arch
    sudo pacman -R timeshift
  7. Manage user data inclusion in snapshots

    master

    By default, Timeshift excludes user data (e.g., documents, pictures, music) to prevent accidental overwrites during a system restore and to save space.

    To include user-specific configuration files, you can enable the "Include hidden items" option in the Settings > Users tab. This will back up and restore the .hidden files and directories in your home folder.

    Warning: It is generally not recommended to include large amounts of user data in snapshots, as this data will be overwritten when you restore a previous system state.

  8. Configure snapshot levels and schedules

    master

    Timeshift allows you to set multiple snapshot levels to ensure system recovery points are available at different intervals. You can specify the number of snapshots to retain for each level in the Settings window.

    Supported levels and their tags:

    • H: Hourly
    • D: Daily
    • W: Weekly
    • M: Monthly
    • B: Boot (Created with a 10-minute delay after system startup to avoid affecting boot speed)
    • O: On-demand (Manually created snapshots)
  9. Configure BTRFS subvolumes for Timeshift

    master

    To use BTRFS snapshots, your system must follow an Ubuntu-type layout using @ and @home subvolumes. Systems that use the @ subvolume but keep /home on a non-BTRFS partition are also supported.

    Important: If you encounter the error Text file busy / btrfs returned an error: 256 / Failed to create snapshot, it is likely because a Linux swapfile is located within the @ or @home subvolumes. To resolve this, relocate the swapfile to a separate subvolume, such as @swap.

  10. Manage disk space for snapshots

    master

    Timeshift requires significant disk space on the selected snapshot device. If you are running out of space, use the following strategies:

    1. Reduce backup levels: In the settings, uncheck unnecessary backup levels so only one is selected.
    2. Reduce snapshot retention: In the Schedule tab, set the number of snapshots to be kept to 5 or fewer.
    3. Manual snapshots: Disable scheduled snapshots entirely and create them manually as needed.
  11. Verify BTRFS subvolume layout

    master

    If using BTRFS, you can verify if your system meets the required Ubuntu-type layout (@ subvolume) by running the following command. If the output is OK, the layout is compatible.

    grep -E '^[^#].+/\s+btrfs' /etc/fstab | \
    grep -oE 'subvol=[^,]+' | \
    cut -d= -f2 | \
    grep -qE '^/?@$' && \
    echo 'OK' || \
    echo 'Not OK'
  12. Set default BTRFS subvolume

    master

    If you need to manually set the default BTRFS subvolume to /, you can use this script. Note that this requires mounting the BTRFS partition first.

    MP="$(mktemp -d)"
    mount | awk '/on \/ type btrfs/{print $1}' | sudo xargs -I{} mount {} "$MP" && \
    sudo btrfs subvolume set-default 5 "$MP"; \
    sudo umount "$MP"