当前位置:首页 > 电脑常识 > 正文

linux 全新的备份神器 Duplicity 8090安适门户

11-22 电脑常识

Duplicity 使用 librsync 出产一个非常小的特别备份。它能够生成递增备份,然后使用 GPG 进行加密,能够适用常用的要领发送至另一个处事器上,好比:scp、ftp、sftp、rsync等等。可以从任何目录开始备份,不限于加载点(mountpoint),并且可以指定你想要排除的文件。
安置也很简单,使用yum安置和下载duplicity的源码包,编译安置也可以。
1.安置所需要依赖(安置epel源)
yum install -y gcc-c++ librsync python-lockfile python-urllib3 python-setuptools python-devel librsync-devel
2.下载duplicity源码包
wget -c https://code.launchpad.net/duplicity/0.7-series/0.7.07/+download/duplicity-0.7.07.tar.gz
3.解压,并安置
tar xvf duplicity-0.7.07.tar.gz
cd duplicity-0.7.07
python setup.py install
4.验证是否安置告成,并检察版本
echo $?
duplicity -V
如果使用yum无法安置,存候置epel的扩展源,再yum安置

所有详细信息请参考

注意:在设置备份时,请同时备份好设置的密钥,如果密钥丢掉,你备份的数据也无法解密,所以把密钥刻录多张cd作为多个备份。

语法:
duplicity [actions] [options] source_directory target_url
action:
full           会强制的完整备份,即使可以使用增量备份
incr           使用增量备份,但是第一次备份时会忽略,而使用完整备份
verify          对照备份和当前文件的改削时间
list-current-files    列出当前最新备份的文件
collection-status    列出备份的状态,有几多个完整备份及增量备份,备份的时间等等.
例如:
1.列出备份文件的状态
duplicity collection-status --ssh-options="-oPort=8888 -oIdentityFile=/home/abc/sK/id_rsa" sftp://mysftp@backup/  /upload/
#--ssh-options 指定链接所使用的端标语
#-oIdentityFile 指定ssh密钥的位置
2.删除存在的时间赶过1年的文件
duplicity remove-older-than 1Y --force ftp://ftpuserID@ftp.domaim.com/passwords
#--force 如果不加上这个这个参数,则是列出要删除的文件,而不会删除他们。
#remove-older-than 删除比指按时间要旧的文件
#--no-encryption   不加密,
待续。。。。
格局如下:
duplicity [full|incremental] [options] source_directory target_url
duplicity verify [options] [--compare-data] [--file-to-restore ] [--time time] source_url
target_directory
duplicity collection-status [options] [--file-changed ]
target_url
duplicity list-current-files [options] [--time time] target_url
duplicity [restore] [options] [--file-to-restore ] [--time time] source_url
target_directory
duplicity remove-older-than  [options] [--force] target_url
duplicity remove-all-but-n-full  [options] [--force] target_url
duplicity remove-all-inc-of-but-n-full  [options] [--force] target_url
duplicity cleanup [options] [--force] [--extra-clean] target_url
编纂脚本,执行命令备份
vim duplicity.sh
#!/bin/bash
# set up the GPG private key password
#这里设置的PASSPHRASE就是你的GPG密钥的暗码
#PASSPHRASE=xxxxxx
#export PASSPHRASE
#set the ssh key password
#FTP_PASSWORD是你的ssh密钥的暗码,导入到环境中就不用手动输入了
FTP_PASSWORD=mypassword
export FTP_PASSWORD
#upload server root ,exclude /proc /sys /tmp to sftp server,and no encryption
#下面是备份根目录,--exclude暗示将 /proc /sys /tmp 除外 ,这里需要注意的是,duplicity文档中出格注明了如果你要备份根,那么必需要把 /proc除外
#下面的 --dry-run暗示并没有实际运行,只是测试,而 --ssh-options后面的是ssh的一些设置,端标语为8888,ssh密钥的位置.
duplicity -v5 --dry-run --progress   --no-encryption --ssh-options="-oPort=8888 -oIdentityFile=/home/xx/private/id_rsa" --exclude /proc --exclude /sys --exclude /tmp / sftp://mysftp@youserver.locastion/upload/#unset varunset FTP_PASSWORD
备份虽然重要,单恢复更为重要。
在备份前,先列出所有备份的文件,确定好备份的文件在做相应的答复,如果命令不是很熟练的话,请先本身在另外机器上演戏几遍,以免产生不须要的错误。
1.列出备份的文件
duplicity list-current-files scp://mybackup/directoryname/home/
恢复某个特定日期的文件   添加:--restore-time "2016-09-22"

结论:Duplicity 非常棒,而且速度也很快。这是因为善用 libsync 让备份变得很小,同时也因为他们连结了备份文件的索引,这样为了获得文件列表无需对整个备份进行读取。备份文件很小,划分为多个小文件,这样源机器就不需太多的姑且空间。用起来也非常简单:他们能够完成所有递增和完整备份的事情,从而让你能够把存眷焦点放在对什么进行备份和恢复上。

温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/pc/13351.html

博客主人杰米WWW
杰米博客,为大家提供seo以及it方面技巧喜欢的朋友收藏哦!
  • 11365文章总数
  • 1378074访问次数
  • 建站天数
  •