Wednesday, 1 October 2014

Introducing Timeshift BTRFS


Timeshift BTRFS is a fork of Timeshift for BTRFS filesystem. You can use this application only if your Linux system is installed on a BTRFS partition.

BTRFS is an advanced, experimental file system with in-built support for filesystem snapshots. Since snapshots are natively supported by the filesystem, creation and restoration of snapshots is extremely fast and takes less than two seconds. The snapshots initially do not take any space on disk and slowly "grow" in size as the original system files get modified over time. Read more about it at the following links:

Bitrot and atomic COWs: Inside "next-gen" filesystems

Features:

Super-fast Snapshot Creation

Creating a BTFS snapshot is very fast. It usually takes one or two seconds.

BTRFS snapshots are created by creating a subvolume that shares files with the root subvolume. Files don't need to be copied (only file system metadata needs to be updated) which makes the process very fast.

Snapshots takes ZERO space initially

BTRFS is a copy-on-write filesystem. This means that when an existing file is modified, changes are written to new data blocks instead of overwriting older data blocks. So we can have multiple copies of a file which share data blocks with each other thus saving disk space.

Because of this, snapshots do not occupy any extra space on disk when it is first created. As the system files get modified over a period of time, the modified files will get duplicated by the file system and the snapshot will gradually "grow" to take up extra space.

Super-fast Restore

Snapshots are restored by renaming subvolumes. Since files don't need to be copied or deleted, restoring a snapshot is very fast and takes less than a second.

You can continue working on your current system after restoring. There is no need to reboot. The restored snapshot will become active the next time you reboot your system.

Your current system will be preserved as a "snapshot" which you can restore later to undo the restore.

Also since the snapshot is a perfect copy of your system (nothing is excluded) the system that you get after restore will be perfectly same as the system that you had snapshotted.

Differences between Timeshift RSYNC and Timeshift BTRFS

The differences are listed below.

Timeshift BTRFSTimeshift RSYNC
Snapshots are a perfect copy of the root and home subvolumes. Snapshots are not perfect copies as some files and directories are always excluded.
No option to exclude files and directories. All files in user's home directory (including documents) will be reverted to the previous version after doing a restore. Latest versions of files will be preserved in a new snapshot created before restore Files and directories can be excluded to save disk space. Dynamic directories are excluded by default (/dev, /proc, ..) and additional directories can be specified by user (internet cache, ..)
Snapshot do not take any extra space on disk initially First snapshot requires space equal to system size. Subsequent snapshots create copies of files that have changed.
System partition must be formatted with BTRFS file system. System partition can be formatted with any file system. Backup partition can have any Linux file system that supports hard-links (ext3, ext4, reiserfs, etc)
Snapshot must be saved on the same device Snapshot can be saved on other devices also
Snapshot creation takes less than 2 seconds First snapshot can take upto 10 minutes to create since all files are copied. Subsequent snapshots are faster since only changed files are copied.
Snapshots can be restored without having to reboot the running system immediately. System will be rebooted after snapshot is restored.
Restoring a snapshot does not delete or overwrite any files on the current system. There is no data loss as the current system will be preserved as another snapshot. Modified system files will be overwritten by files from snapshot. New files are copied and extra files are deleted.


Installation

Ubuntu 12.04, 14.04 and 14.10 users can install from PPA:

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

Installers for other Linux distributions are available at following links:

timeshift-btrfs-latest-i386.run (32-bit, 200 KB)
timeshift-btrfs-latest-amd64.run (64-bit, 200 KB)


Donate

If you wish to support the development of this program, please consider purchasing a support subscription for $10 or leaving a donation using the PayPal link below. Your contributions will help in keeping this project alive and to develop it further.

Options

13 comments:

  1. I got this error: "BTRFS partition '/dev/sda4' has an unsupported subvolume layout. Only ubuntu-type layouts with @ and @home subvolumes are currently supported."
    So, how can I create @ and @home subvolumes and use for root mount point / ?

    ReplyDelete
    Replies
    1. When you install Ubuntu/Linux Mint on a BTRFS partition, it automatically creates the @ and @home subvolumes. Format the partition to BTRFS and do a fresh install of Ubuntu.

      Delete
    2. sda3 is mount in / with two subvolume (@ and @home), but, still got the same error

      > manhtuvjp@Vostro-3560:~$ mount | grep btrfs
      > /dev/sda3 on / type btrfs (rw,noatime,autodefrag,compress-force=lzo,space_cache)
      > /dev/sda5 on /media/DATA type btrfs (rw,noatime,autodefrag,compress-force=lzo,space_cache)
      > /dev/sda4 on /home type btrfs (rw,noatime,autodefrag,compress-force=lzo,space_cache)

      > manhtuvjp@Vostro-3560:~$ sudo btrfs subvol list /
      > ID 277 gen 634 top level 5 path @home
      > ID 278 gen 681 top level 5 path @

      "BTRFS partition '/dev/sda3' has an unsupported subvolume layout. Only ubuntu-type layouts with @ and @home subvolumes are currently supported."

      Delete
    3. Which Linux distribution are you using?

      Delete
    4. Please mail me the log file in folder "/var/log/timeshift-btrfs" (teejeetech at gmail dot com).

      Delete
    5. No need. I do following steps to solve problem:
      1. Run:
      > sudo btrfs subvol set-default 5 /
      2. Open Timeshift-Btrfs and backup/restore
      3. Run:
      > sudo btrfs subvol set-default [@ id or @home id] /
      4. Reboot

      Delete
    6. Keep the default subvol ID set to 5. There is no need to run the command in Step-3.

      Ubuntu mounts the @ and @home subvolumes by name, not by id.
      So when you restore a snapshot Timeshift will replace the @ and @home subvolume and after reboot Ubuntu will mount it automatically. There is no need to do set-default.

      Delete
  2. Hello.

    OS: Xubuntu 14.04 64-bit, updated

    I am a newcomer to Timeshift RSYNC v.1.6.2. So pardon my newbie's questions:
    - How do you save snapshots to external devices (a Flash drive, e.g)?
    Flash drives don't appear in the application's box as a possible target.

    - How to restore a snapshot in case the OS were unaccessible and so access to Timeshift?

    With thankful regards.

    ReplyDelete
    Replies
    1. The external device must be formatted with a Linux partition (ext3/4). Then it will appear in the drop-down box for selecting backup device.

      If OS is not accessible you can boot from the Ubuntu Live CD or Live USB and install Timeshift on the live system. Then select the backup device and restore the snapshot.

      Delete
    2. Your explanation is very clear.
      I would never have guessed answer #1. How silly of me, though it's obvious now. But I suspected as much for #2 while not being sure of it.

      Thank you very much for your helpfullness , Tony!
      Let me wish you a pretty continuation in your pursuit.
      From Belgium,
      Richard.

      Delete
  3. Hi

    I have downloaded Timeshift BTRFS 1.1 and am unable to use the "clone" option, as that is missing from the interface. Timeshift 1.7.2 has a clone option listed in the interface. Is this a resolvable issue via the CLI?

    Kind regards
    Pete

    ReplyDelete

If you are reporting an issue and commenting as an anonymous user, please leave your email address so that I can get in touch with you.