如何在Ubuntu/Debian Linux上编译和安装Tarsnap
时间:2020-01-09 14:16:57 来源:igfitidea点击:
Tarsnap服务是Linux,OSX,* BSD或类似UNIX系统的安全在线备份系统。
他们将数据加密并存储在Amazon S3中。
这些服务还使用类似rsync的算法,并且仅备份自上次转储以来已更改的备份数据。
备份受仅备份操作员或sysadmin知道的安全密钥保护。
如何在Ubuntu或Debian Linux系统上安装tarsnap客户端?
预先构建的Ubuntu或Debian Linux二进制文件不适用于Tarsnap。
您必须下载源代码并在系统上进行编译。
因此,您需要以下内容:
- GNU GCC和其他工具
- 的OpenSSL
- zlib
在本快速教程中,您将学习如何在Ubuntu或Debian Linux系统上从源代码安装和编译tarsnap客户端。
步骤1:下载Tarsnap
执行以下wget命令:
$ wget https://www.tarsnap.com/download/tarsnap-autoconf-1.0.37.tgz $ wget https://www.tarsnap.com/download/tarsnap-sigs-1.0.37.asc $ wget https://www.tarsnap.com/tarsnap-signing-key-2015.asc
步骤2:验证Tarsnap
要使用GnuPG验证下载的tarball,请执行:
$ gpg --import tarsnap-signing-key-2015.asc
输出示例:
gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key 3DA2BCE3: public key "Tarsnap source code signing key (Colin Percival) <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) gpg: no ultimately trusted keys found
尝试验证软件签名:
$ gpg --decrypt tarsnap-sigs-1.0.37.asc
输出示例:
gpg: Signature made Thu 10 Mar 2015 12:57:03 AM UTC using RSA key ID 3DA2BCE3 gpg: Good signature from "Tarsnap source code signing key (Colin Percival) <[email protected]>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: ECAE BA77 D19D 1EE0 CAF1 628F BC5C FA09 3DA2 BCE3
添加此密钥的信任网:
$ gpg --edit-key [email protected] trust
现在再次验证:
$ gpg --decrypt tarsnap-sigs-1.0.37.asc
输出示例:
SHA256 (tarsnap-autoconf-1.0.37.tgz) = fa999413651b3bd994547a10ffe3127b4a85a88b1b9a253f2de798888718dbfa gpg: Signature made Thu 10 Mar 2015 12:57:03 AM UTC using RSA key ID 3DA2BCE3 gpg: Good signature from "Tarsnap source code signing key (Colin Percival) <[email protected]>"
验证压缩包的SHA256哈希与签名的SHA256哈希文件中的值匹配:
$ shasum -a 256 tarsnap-autoconf-1.0.37.tgz
输出示例:
fa999413651b3bd994547a10ffe3127b4a85a88b1b9a253f2de798888718dbfa tarsnap-autoconf-1.0.37.tgz
步骤3:安装必要的软件以在Ubuntu/Debian上编译tarsnap
执行以下命令来安装软件:
$ sudo apt update $ sudo apt upgrade $ sudo apt install build-essential $ sudo apt install libc6-dev libssl-dev zlib1g-dev e2fslibs-dev
输出示例:
Reading package lists... Done Building dependency tree Reading state information... Done libc6-dev is already the newest version (2.23-0ubuntu5). libc6-dev set to manually installed. The following additional packages will be installed: comerr-dev libssl-doc Suggested packages: doc-base The following NEW packages will be installed: comerr-dev e2fslibs-dev libssl-dev libssl-doc zlib1g-dev 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 2,831 kB of archives. After this operation, 11.5 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.service.networklayer.com/ubuntu xenial/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4 [168 kB] Get:2 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.5 [1,344 kB] Get:3 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libssl-doc all 1.0.2g-1ubuntu4.5 [1,078 kB] Get:4 http://mirrors.service.networklayer.com/ubuntu xenial/main amd64 comerr-dev amd64 2.1-1.42.13-1ubuntu1 [38.2 kB] Get:5 http://mirrors.service.networklayer.com/ubuntu xenial/main amd64 e2fslibs-dev amd64 1.42.13-1ubuntu1 [203 kB] Fetched 2,831 kB in 0s (12.7 MB/s) Selecting previously unselected package zlib1g-dev:amd64. (Reading database ... 86681 files and directories currently installed.) Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4_amd64.deb ... Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4) ... ... .. ... Setting up comerr-dev (2.1-1.42.13-1ubuntu1) ... Setting up e2fslibs-dev (1.42.13-1ubuntu1) ...
步骤4:提取焦油球
输入以下tar命令:
$ tar zxvf tarsnap-autoconf-1.0.37.tgz
步骤5:编译tarsnap软件
执行以下命令:
$ cd tarsnap-autoconf-1.0.37/ $ ./configure && make all
要安装软件,请执行:
$ sudo make install
验证安装:
$ type -a tarsnap `tarsnap is /usr/local/bin/tarsnap`
如何使用Tarsnap客户端?
首先,您需要访问Tarsnap服务和帐户管理界面。
Tarsnap像预付费手机一样以预付费方式运行。
设置配置文件
输入以下cp命令:
$ sudo cp -v /usr/local/etc/tarsnap.conf{.sample,}
输出示例:
'/usr/local/etc/tarsnap.conf.sample' -> '/usr/local/etc/tarsnap.conf'
生成用于tarsnap的密钥文件
使用tarsnap-keygen命令生成加密密钥,在tarsnap服务器中注册,并编写用于tarsnap的密钥文件:
$ sudo tarsnap-keygen \ --keyfile /root/tarsnap.key \ --user [email protected] \ --machine apache42
确保将/root/tarsnap.key文件复制到安全的地方。
如何进行第一次备份?
语法类似于tar命令。
在下面的示例中,我要备份/root,/etc和/var/www/html目录:
$ sudo /usr/local/bin/tarsnap -c -f apache42-20160104 /root /etc /var/www/html
其中:
-c
:创建一个新的档案- -f:存档名称由我的$HOSTNAME(apache42)和日期组成,格式为YYYYMMDD(20160104)
/root/etc/var/www/html
:要备份的多个目录的列表
如何进行增量备份?
语法如下(仅注意日期戳已更改):
$ sudo /usr/local/bin/tarsnap -c -f apache42-20160105 /root /etc /var/www/html
第二天:
$ sudo /usr/local/bin/tarsnap -c -f apache42-20160106 /root /etc /var/www/html
如何打印备份服务器上存储的存档列表?
执行以下命令:
$ tarsnap --list-archives $ tarsnap --list-archives | sort
输出示例:
Please enter passphrase for keyfile /root/tarsnap.key: apache42-20150603 apache42-20150622 apache42-20150726 .... ... apache42-20160101
如何还原名为apache42-20150622的档案?
语法为:
$ sudo tarsnap -x -f apache42-20150622 $ sudo ls /var/www/html