当前位置首页 > Ubuntu知识

如何使用TimeShift备份和还原UbuntuLinux

阅读次数:321 次  来源:admin  发布时间:

https://linux.cn/article-11619-1.html

你是否曾经想过如何备份和还原 Ubuntu 或 Debian 系统?Timeshift 是一款自由开源工具,可让你创建文件系统的增量快照。你可以使用 RSYNC 或 BTRFS 两种方式创建快照。

让我们深入研究并安装 Timeshift。在本教程,我们将安装在 Ubuntu 18.04 LTS 系统上。

在 Ubuntu / Debian Linux 上安装 TimeShift

TimeShift 尚未正式托管在 Ubuntu 和 Debian 仓库中。考虑到这一点,我们将运行以下命令来添加 PPA:

# add-apt-repository -y ppa:teejee2008/ppa

如何使用TimeShift备份和还原UbuntuLinux

Add timeshift repository

接下来,使用以下命令更新系统软件包:

# apt update

成功更新系统后,使用以下 apt 命令安装 Timeshift:

# apt install timeshift

如何使用TimeShift备份和还原UbuntuLinux

apt install timeshift

准备备份存储设备

最佳实践要求我们将系统快照保存在系统硬盘之外的单独的存储卷上。对于本指南,我们将使用 16GB 闪存作为第二个驱动器,并在该驱动器上保存快照。

# lsblk | grep sd

如何使用TimeShift备份和还原UbuntuLinux

lsblk sdb ubuntu

为了将闪存用作快照的备份位置,我们需要在设备上创建一个分区表。运行以下命令:

# parted /dev/sdb mklabel gpt # parted /dev/sdb mkpart primary 0% 100% # mkfs.ext4 /dev/sdb1

如何使用TimeShift备份和还原UbuntuLinux

create partition table on drive ubuntu

在 USB 闪存上创建分区表后,我们可以开始创建文件系统的快照!

使用 Timeshift 创建快照

要启动 Timeshift,使用应用程序菜单搜索 “Timeshift”。

如何使用TimeShift备份和还原UbuntuLinux

Access timeshift

单击 Timeshift 图标,系统将提示你输入管理员密码。提供密码,然后单击验证。

如何使用TimeShift备份和还原UbuntuLinux

Authentication required

接下来,选择你喜欢的快照类型。

如何使用TimeShift备份和还原UbuntuLinux

Select rsync optio

点击 “Next”。选择快照的目标驱动器。在这里,我的位置是标记为 /dev/sdb 的外部 USB 驱动器。

如何使用TimeShift备份和还原UbuntuLinux

Select snapshot locatio

接下来,定义快照级别。级别是指创建快照的时间间隔。你可以选择每月、每周、每天或每小时的快照级别。

如何使用TimeShift备份和还原UbuntuLinux

Select snapshot level

点击 “Finish”。

在下一个窗口中,单击 “Create” 按钮开始创建快照。此后,系统将开始创建快照。

如何使用TimeShift备份和还原UbuntuLinux

Create snapshot

最后,你的快照将显示如下:

如何使用TimeShift备份和还原UbuntuLinux

Snapshot created

从快照还原 Ubuntu / Debia

创建系统快照后,现在让我们看看如何从同一快照还原系统。在同一个 Timeshift 中,单击快照,然后单击 “Restore” 按钮,如图所示。

如何使用TimeShift备份和还原UbuntuLinux

Restore snapshot

接下来,将提示你选择目标设备。保留默认选择,然后点击 “Next”。

如何使用TimeShift备份和还原UbuntuLinux

Select target device

恢复过程开始之前,Timeshift 将会试运行。

如何使用TimeShift备份和还原UbuntuLinux

Comparing files dry ru

在下一个窗口中,点击 “Next” 按钮确认显示的操作。

如何使用TimeShift备份和还原UbuntuLinux

Confirm actio

如图所示,你会看到警告和免责声明。点击 “Next” 初始化恢复过程。

此后,将开始还原过程,最后,系统之后将重新启动到快照定义的早期版本。

如何使用TimeShift备份和还原UbuntuLinux

Restoring snapshot

总结

如你所见,使用 TimeShift 从快照还原系统非常容易。在备份系统文件时,它非常方便,并允许你在系统故障时进行恢复。因此,不要害怕修改系统或弄乱系统。TimeShift 使你能够返回到一切运行平稳的时间点。

https://www.linuxtechi.com/timeshift-backup-restore-ubuntu-linux/

https://linuxconfig.org/ubuntu-20-04-system-backup-and-restore

In this tutorial we will use Timeshift to create the full system backup snapshot of Ubuntu 20.04 system. Furthermore, you will learn how to restore from your previously created backup snapshot.

In this tutorial you will learn:

How to create full system backup snapshot How to restore from backup snapshot How to create and restore backup from the command line

如何使用TimeShift备份和还原UbuntuLinux

Ubuntu 20.04 System Backup and Restore Software Requirements and Conventions Used Software Requirements and Linux Command Line Conventions Category Requirements, Conventions or Software Version Used System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa Software timeshift Other Privileged access to your Linux system as root or via the sudo command. Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command

$ - requires given linux commands to be executed as a regular non-privileged user Ubuntu 20.04 System Backup and Restore step by step instructio

Using the following steps we will first create system backup of the Ubuntu 20.04 system using the Timeshift graphical user interface. Later we will restore from the previously created system backup snapshot.

First step is to install the Timeshift backup utility on your Ubuntu 20.04 System. To do this execute the following command:

$ sudo apt install timeshift

Create Backup by using the Timeshift GUI Create system backup Open the timeshift application via top left Activities menu.

如何使用TimeShift备份和还原UbuntuLinux

Upon opening the timeshift application you will be greeted with a wizard to help you schedule your backups. Here you have two options. First is to use the rsync as a main backup tool or take an advantage of an inherent BRTFS built-in file system features. In this example we will use rsync. Select RSYNC and hit the Next button. SUBSCRIBE NEWSLETTER & RSS

Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

如何使用TimeShift备份和还原UbuntuLinux

Select backup destination. timeshift will search your system for available file-system partition and provide you with an option to where to create backup file. 如何使用TimeShift备份和还原UbuntuLinux Select how often you wish to perform the system backup and how many backup snapshots you wish to retrain before the first backup is overwritten. 如何使用TimeShift备份和还原UbuntuLinux As the screenshot indicates the home directories are excluded by default. Depending on you work environment select whether you wish to include home directories into the backup. 如何使用TimeShift备份和还原UbuntuLinux This will conclude your initial backup schedule setup. Hit the Finish button. 如何使用TimeShift备份和还原UbuntuLinux The backup has not been created yet. You can either wait until the timeshift automatically triggers the backup or simply hit the Create button to perform the previously predefined backup now. 如何使用TimeShift备份和还原UbuntuLinux Wait for the backup to complete. 如何使用TimeShift备份和还原UbuntuLinux If all went well you should now see your first backup snapshot listed. Restore from backup 如何使用TimeShift备份和还原UbuntuLinux At this point we will restore the system from the previously created system backup snapshot. Select a backup snapshot from which you wish to restore and click on the Restore button. 如何使用TimeShift备份和还原UbuntuLinux Timeshift give you an option on how to restore from your backup. Unless you know what you are doing simply hit the Next button to go with the default. SUBSCRIBE NEWSLETTER & RSS

Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

如何使用TimeShift备份和还原UbuntuLinux

The Timeshit will provide you with a list of changes it will take to restore from the backup just to make sure no data is lost in the process. 如何使用TimeShift备份和还原UbuntuLinux Once you hit the Next button the system will be restored and restarted. All done. Create and restore backup by using the Timeshift's command line Create a first backup simply by executing the below command:
$ sudo timeshift --create
First run mode (config file not found)
Selected default snapshot type: RSYNC
Mounted /dev/sda2 at /media/root/359151f5-efb9-483d-a738-894d57e2d8c8.
Selected default snapshot device: /dev/sda2
------------------------------------------------------------------------------
Estimating system size...
Creating new snapshot...(RSYNC)
Saving to device: /dev/sda2, mounted at path: /media/root/359151f5-efb9-483d-a738-894d57e2d8c8
Synching files with rsync...
Created control file: /media/root/359151f5-efb9-483d-a738-894d57e2d8c8/timeshift/snapshots/2020-02-19_18-32-36/info.json
RSYNC Snapshot saved successfully (39s)
Tagged snapshot '2020-02-19_18-32-36': ondemand

The above command will also create a new configuration file located at the following location: /etc/timeshift.json. List all your currently created system backup screenshots:

$ sudo timeshift --list
Device : /dev/sda2
UUID   : 359151f5-efb9-483d-a738-894d57e2d8c8
Path   : /media/root/359151f5-efb9-483d-a738-894d57e2d8c8
Mode   : RSYNC
Device is OK
1 snapshots, 197.7 GB free

Num     Name                 Tags  Description  
------------------------------------------------------------------------------
0    >  2020-02-19_18-32-36  O 

Restore from the backup snapshot:

$ sudo timeshift --restore --snapshot "2020-02-19_18-32-36"

Delete selected backup snapshot:

$ sudo timeshift --delete  --snapshot '2014-10-12_16-29-08'
上一篇:CentOS下安装JDK7转载CentOS下安装JDK7
下一篇:RHEL/Centos下VSFTPD服务器搭建