Timeshift 主要用于备份和恢复系统,
有图形界面和命令行版本(timeshift --help
)。
Backup System
安装 Mint 20 Xfce 系统时,/ 和 /home 挂载不同的磁盘分区(sda5 和 sda6), 安装后磁盘使用情况如下:
leo@tcserver:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 1.5M 3.2G 1% /run
/dev/sda5 92G 8.9G 78G 11% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda6 301G 1.1G 285G 1% /home
tmpfs 3.2G 16K 3.2G 1% /run/user/1000
执行 sudo timeshift-gtk
启动 Timeshift 界面(或者在 launcher 里输入 timeshift 启动),
设置如下:
- Select snapshot type: Rsync
- Select snapshot location: /dev/sda6
确定后点击 Create 创建镜像,再次检查磁盘使用情况:
leo@tcserver:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 1.6M 3.2G 1% /run
/dev/sda5 92G 8.9G 78G 11% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda6 301G 7.5G 278G 3% /home
tmpfs 3.2G 16K 3.2G 1% /run/user/1000
leo@tcserver:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 350M 0 part
├─sda2 8:2 0 1.3T 0 part
├─sda3 8:3 0 1K 0 part
├─sda5 8:5 0 93.3G 0 part /
└─sda6 8:6 0 306.4G 0 part /run/timeshift/backup
可以看到 sda6 磁盘占用增加了 6.4 GB,sda5 不变。
Timeshift 在备份分区的根目录下创建 timeshift 目录,
所以这里所有备份都保存在 /home/timeshift 下。
同时 lsblk
显示 sda6 还被挂载到 /run/timeshift/backup 下,
也就是说 sda6 被同时挂载到文件树的两个位置上:
leo@tcserver:~$ mount -l|grep sda6
/dev/sda6 on /home type ext4 (rw,relatime)
/dev/sda6 on /run/timeshift/backup type ext4 (rw,relatime)
其他检查挂载情况的命令:
findmnt | grep sda6
cat /proc/mounts
is the same asmount -l
创建好备份后,点击 Comments 列,可以为此备份添加说明,方便恢复的时候选择。
也可以用命令行创建备份:timeshift --create --comments "basic system" --tags D
。
多个系统挂载同一个 /home 分区,使用相同的 timeshift 目录。
Resotre System from Live USB
Boot machine with Mint 20 USB Live, start Timeshift app from Start menu.
- Select snapshot type: Rsync
- Select snapshot location: /dev/sda5 (the partiton has timeshift folder)
- In the snapshot list, select a snapshot previously created and click Restore
- Select target device: ensure the listed target is correct
Then Timeshift compare the snapshot with the actual disk, list actions to perform. After Comfirm actions the restoring is executed.
This tool can also be used to restore boot loader and grub menu.
Configuration
Timeshift 有图形化配置界面,配置结果保存在 /etc/timeshift.json 里。 此配置文件的模板文件是 /etc/default/timeshift.json。
Timeshift in Other distros
Fedora 32 can install with dnf install timeshift
.
CentOS 8 does NOT have this package, even after installing EPEL.