码迷,mamicode.com
首页 > 系统相关 > 详细

linux 全新的备份神器 Duplicity

时间:2016-09-23 21:44:54      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:详细信息   服务器   linux   加密   

    linux 全新的备份神器  Duplicity

        Duplicity 使用 librsync 生产一个非常小的额外备份。它能够生成递增备份,然后使用 GPG 进行加密,能够适用常用的方法发送至另一个服务器上,比如:scp、ftp、sftp、rsync等等。可以从任何目录开始备份,不限于加载点(mountpoint),并且可以指定你想要排除的文件。

    安装也很简单,使用yum安装和下载duplicity的源码包,编译安装也可以。

    如果使用yum无法安装,请安装epel的扩展源,再yum安装

     www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm

    所有详细信息请参考http://duplicity.nongnu.org

    http://duplicity.nongnu.org/duplicity.1.html  

    

    注意:在设置备份时,请同时备份好设置的密钥,如果密钥丢失,你备份的数据也无法解密,所以把密钥刻录多张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 删除比指定时间要旧的文件

    3.


    格式如下:

duplicity [full|incremental] [options] source_directory target_url

duplicity verify [options] [--compare-data] [--file-to-restore <relpath>] [--time time] source_url

target_directory

duplicity collection-status [options] [--file-changed <relpath>]

target_url

duplicity list-current-files [options] [--time time] target_url

duplicity [restore] [options] [--file-to-restore <relpath>] [--time time] source_url

target_directory

duplicity remove-older-than <time> [options] [--force] target_url

duplicity remove-all-but-n-full <count> [options] [--force] target_url

duplicity remove-all-inc-of-but-n-full <count> [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 让备份变得很小,同时也因为他们保持了备份文件的索引,这样为了获得文件列表无需对整个备份进行读取。备份文件很小,划分为多个小文件,这样源机器就不需太多的临时空间。用起来也非常简单:他们能够完成所有递增和完整备份的工作,从而让你能够把关注焦点放在对什么进行备份和恢复上。、





待续。。。。。。。。。。。。

本文出自 “IT阿宝” 博客,请务必保留此出处http://907832555.blog.51cto.com/4033334/1855921

linux 全新的备份神器 Duplicity

标签:详细信息   服务器   linux   加密   

原文地址:http://907832555.blog.51cto.com/4033334/1855921

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!