Timeshift with Debian

I am using Timeshift to take a snapshot of my darktower NAS and workstations just in case of the failed upgrade were to occur. I could rollback to the previous snapshot then I am good to go.

Preparing the USB drive

Preparing an external device such as USB thumb drive for storing the Timeshift snapshots. I am using a 32GB USB stick in this post. Timeshift requires the device to be in either ext2, ext3, ext4, xfs. First, we need to locate the drive and we need to create a partition.

# To find where your flash drive or target drive is.
lsblk -d -o name,model,size,tran

# Create a partition. Make sure to select the correct name/device.
fdisk /dev/sdk

# Delete any existing partition
Command (m for help): d

# Create a new partition using GPT table
Command (m for help): g

# Create new partition and select the default options
Command (m for help): n

# Write the new config to the drive
Command (m for help): w

Once we have a partition, we need to format the partition to ext4. The number “1” at the end is the partition we create earlier.

mkfs.ext4 -L TIMESHIFT /dev/sdk1

Timeshift

Now that we have a working drive to store the snapshots created by Timeshift, we need to install Timeshift. If you are using a non-Debian based distro, you can check pkgs.org.

apt install timeshift

By default, Timeshift would use the /boot to store the snapshots. This is not going to work since Timeshift requires bigger storage than the /boot partition. You can see this required 3.2GB storage size in Figure 1. To change the location of the snapshots, execute the command below. I used the UUID of my USB drive that I prepared earlier instead of the device name. You can get the UUID using lsblk -f command.

timeshift --snapshot-device e2f3d18d-6018-4ce1-b6ff-7edec3d39318 

You can verify the Device location and the Path from the screenshot shown in Figure 1.

Figure 1

To set the settings like schedule, we would need edit the /etc/timeshift.json file. In my case, I am going to set timeshift to take snapshot weekly. Therefore, I will change the value of “schedule_weekly” from “false” to “true”.

{
  "backup_device_uuid" : "e2f3d18d-6018-4ce1-b6ff-7edec3d39318",
  "parent_device_uuid" : "",
  "do_first_run" : "false",
  "btrfs_mode" : "false",
  "include_btrfs_home_for_backup" : "false",
  "include_btrfs_home_for_restore" : "false",
  "stop_cron_emails" : "true",
  "btrfs_use_qgroup" : "true",
  "schedule_monthly" : "false",
  "schedule_weekly" : "true",
  "schedule_daily" : "false",
  "schedule_hourly" : "false",
  "schedule_boot" : "false",
  "count_monthly" : "2",
  "count_weekly" : "3",
  "count_daily" : "5",
  "count_hourly" : "6",
  "count_boot" : "5",
  "snapshot_size" : "3206418962",
  "snapshot_count" : "81850",
  "exclude" : [
    "/home/karlo/**",
    "/var/lib/libvirt/**",
    "/home/hoid/**"
  ],
  "exclude-apps" : [
  ]
}

Create the first snapshot and add the option --tags if necessary. The tags are the following:

  • D – Daily
  • W – Weekly
  • M – Monthly
  • O – On-demand
timeshift --create --comment "first snapshot" --tags D
Figure 2

To restore from a snapshot, you can use the –restore option. You will provided a list if you have multiple snapshots as shown below. Enter the number of the desire restore point.

root@darktower:/mnt/pool/downloads/transmission_complete# timeshift --restore 

Select snapshot:

Num     Name                 Tags  Description                        
------------------------------------------------------------------------------
0    >  2021-03-04_06-27-31  D     first snapshot                     
1    >  2021-03-17_08-05-14  O     second snapshot                    
2    >  2021-03-19_12-42-29  O     third snapshot                     
3    >  2021-04-09_11-04-28  O     fourth snapshot - before updating 

Enter snapshot number (a=Abort, p=Previous, n=Next): 2

You will get prompted to literally press ENTER at every prompt. After going to the prompts, the server will get restarted. Once the system is back, you have successfully restored the system using Timeshift.

Cheers!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x