LSX-blog

Feed Rss

【转载】利用dump和restore实现Linux的备份和还原

02.13.2012, 系统, by .

一,dump的原理,优点及限制
dump和restore默认已经安装在RHEL5中,如果你使用的Linux中没有,可以自己去google中搜一下并下载安装。
使用dump命令时,它会建立一份自上次备份操作以来进行修改过的文件列表,然后把这些文件打包成一个单独的文件。在做备份时,需要指定一个备份级别,它是0-9之间的一个整数。级别为N的转储会对从上次进行的级别小于N的转储操作以来修改过的所有文件进行备份,而级别0就是完全备份。通过这种方式,可以很轻松的实现增量备份,差异备份,甚至每日备份。例如,第一次备份时可选择级别0(具体操作看后面),以后每天做增量备份时就可以每天依次使用级别1,级别2,级别3等等… …;当需要每天做差异备份时,可先选择级别0做完整备份,然后每天都使用同一大于0的级别就行了,比如说第二天用5,第三天也用5,第四天也一样。
使用dump的优点:
1,备份可以跨多卷磁带
2,能备份任何类型的文件,甚至是设备
3,备份时,文件的权限,宿主,宿组,修改时间等都会被保存
4,能够正确处理从未包含任何数据的文件块(孔洞文件)
5,能够做增量,差异备份

它也有不足:
1,每个文件系统必须单独转储备份
2,只有本地计算机的文件系统才能够转储备份(rdump,rrestore可用来弥补此项不足)
当然,使用tar也可以用来实现备份和还原,但tar只能在Linux或Unix环境下使用,对于跨平台的环境,dump使用起来个人感觉更方便一些。
如果有条件,dump也可以将备份存储在磁带上。Linux通常用/dev/st0代表倒带设备,而用/dev/nst0代表非倒带设备,使用倒带设备存储时,当磁带用完它会自动倒带并接着存储,所以会覆盖以前的数据,这样就存在以前数据丢失的风险。这个地方咱们就不详细讨论了。
二,dump的格式,常用参数及使用
格式:dump [-level#] [-acmMnqSuv] [-A file] [-B records] [-b blocksize]
[-d density] [-D file] [-e inode#,inode#,…] [-E file]
[-f file] [-h level] [-I nr errors] [-j zlevel] [-Q file]
[-s feet] [-T date] [-y] [-z zlevel] filesystem
常用参数 Level:备份级别0-9
-B:指定用来备份的磁带的长度,以KB为单位(有些磁带不支持以结束标志判断时,就需要使用到此参数
-b:指定块大小,默认为10
-d:指定密度,默认为1600BPI
-D:设定存储数据库的名称和路径,默认是/etc/dumpdates文件
(-e,-E:与备份文件的inodes数有关的参数)
-f:指定备份文件的路径和名称
-u:更新数据库文件/etc/dumpdates
-s:统计备份所需的空间,一般在备份前做,以防磁带或磁盘空间不足
举例:
dump –0s /dev/sda1
完整备份/dev/sda1前统计一下需多大容量
dump -0u –f /tmp/boot.dump /boot

以完全备份的方式备份/boot分区到文件/tmp/boot.dump,并且更新/etc/dumpdates数据库文件。“0”代表的就是备份级别为完全备份。“u”更新数据库,会将文件的日期,存储级别,文件系统等信息都记录下来。如果从来都不使用-u参数,那么所有的存储都会变为级别0。因为,系统不会有先前备份过当前文件系统的记录。
当以后更改了/boot,比如说内核升级后,如果再想备份,可以按下列方式:
dump -1u –f /tmp/boot1.dump /boot
这样就只会备份完全备份后有变化的文件(级别1大于0)。
如果以后想做增量备份,就依次用级别2,3,4… …
如果想做差异备份,以后就一直用级别1.关于增量备份和差异备份的区别看看下图吧,不详细讲了:


三,查看备份文档中的文件及还原
查看备份文档中的文件和还原就需要用到另外一个工具,restore。
1, 查看备份文档中的文件

-t参数是查看的意思,-f是指定要查看的备份文件。通过以上命令,就可以查看备份文件中备份了哪些文件。
1, 还原备份
还原备份的时候有两种方式可以选择,一种是完全还原,一种是有选择的部分还原。
咱们还是用前面的例子来看,如果你前面备份的/boot分区文件损坏了,这时候你想还原,可以按如下步骤:

-r参数表示重建
如果只是一部分数据丢失了,那么可以使用参数-i通过交互方式来实现文件的选择性还原

这个地方我故意删掉了一个文件initrd-2.6.18-53.el5.img

使用参数-i交互式,并指定备份文件。
通过?来查看可以使用的命令,ls是列出备份文件的内容

通过add来选择要恢复的文件,选定后再ls的时候会标记为*

通过extract还原选定的文件。
提示“Specify next volume”时填如1,它表示是在单独一卷磁带(这里我用的是磁盘的空间)上进行的备份。下面一行提示选“n”,表示不是恢复整个文件系统,而是单个文件。

【转载】利用dump和restore实现Linux的备份和还原 有 48 条回应

  1. This piece of writing will help the internet viewers for
    creating new website or even a weblog from start to end.

    回复
  2. Asking questions are genuinely nice thing if you are
    not understanding something totally, however this piece of writing offers pleasant understanding even.

    回复
  3. Very quickly this web page will be famous amid all blogging users,
    due to it’s good articles or reviews

    回复
  4. Thanks for every other magnificent article.
    Where else may anybody get that kind of information in such a perfect
    means of writing? I have a presentation subsequent week,
    and I’m on the search for such info.

    回复
  5. I really like what you guys are up too. This kind of clever work and exposure!
    Keep up the amazing works guys I’ve incorporated you guys to our blogroll.

    回复
  6. Painter And Decorator Gloucester
    38 Bruton Way
    Gloucester GL1 1DA, United Kingdom
    01452 223268

    回复
  7. Hmm it appears like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to the whole thing. Do you have any tips and hints for first-time blog writers? I’d certainly appreciate it.|

    回复
  8. Hello, Neat post. There’s a problem along with your web
    site in web explorer, could check this? IE still is
    the marketplace leader and a large component of other people will pass over your excellent writing due to this problem.

    回复
  9. I have read so many articles concerning the blogger lovers except
    this piece of writing is actually a fastidious article, keep it
    up.

    回复
  10. Hi there everyone, it’s my first pay a visit at this site, and
    article is in fact fruitful designed for me, keep up posting these posts.

    回复
  11. I know this website offers quality based articles and extra data, is there any other
    web page which offers such stuff in quality?

    回复
  12. Hi! Someone in my Facebook group shared this website with us so I
    came to check it out. I’m definitely loving the
    information. I’m book-marking and will be tweeting
    this to my followers! Exceptional blog and amazing design and style.

    回复
  13. Please let me know if you’re looking for a writer for your weblog.
    You have some really good articles and I believe I would be a good asset.
    If you ever want to take some of the load off, I’d really
    like to write some material for your blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Thank you!

    回复
  14. Heya i am for the primary time here. I found this
    board and I to find It really helpful & it helped
    me out a lot. I’m hoping to offer one thing
    again and help others like you aided me.

    回复
  15. Its like you learn my mind! You seem to grasp so much
    about this, such as you wrote the guide in it or something.
    I feel that you simply can do with a few p.c. to
    force the message home a bit, but instead of that, that is
    magnificent blog. An excellent read. I will definitely be
    back.

    回复
  16. I think everything published made a lot of sense. But, think about this, suppose you were
    to create a killer headline? I mean, I don’t want to tell you how to run your website, but what if you added a
    title that grabbed a person’s attention? I mean 【转载】利用dump和restore实现Linux的备份和还原 – LSX-blog is a little boring.
    You ought to peek at Yahoo’s front page and watch how they write post titles
    to get people to open the links. You might try adding a video or a pic or two to grab readers
    interested about everything’ve written. In my opinion, it could
    bring your posts a little bit more interesting.

    回复
  17. Hey! Someone in my Facebook group shared this website with us so I came
    to take a look. I’m definitely loving the information. I’m book-marking and will be tweeting
    this to my followers! Outstanding blog and brilliant style and design.

    回复
  18. Good day! I could have sworn I’ve visited this blog before but after looking at a few of the posts I realized it’s new to me.
    Anyhow, I’m definitely happy I found it and I’ll be book-marking it and checking back frequently!

    回复
  19. Your style is very unique compared to other people I have read stuff
    from. Many thanks for posting when you’ve got the
    opportunity, Guess I’ll just bookmark this page.

    回复
  20. I don’t even know how I ended up here, but I thought this post was
    good. I don’t know who you are but certainly you’re going to a
    famous blogger if you are not already 😉 Cheers!

    回复
  21. Good way of telling, and good paragraph to take information concerning
    my presentation subject matter, which i am going to present in school.

    回复
  22. Remarkable! Its actually amazing paragraph, I have got much clear idea
    regarding from this post.

    回复
  23. Great post. I was checking constantly this weblog and
    I am impressed! Very helpful information specifically the last section 🙂
    I handle such information a lot. I was seeking this certain info for a long time.
    Thank you and good luck.

    回复
  24. Great article! This is the kind of info that are meant to be shared across
    the web. Disgrace on the search engines for no longer positioning
    this submit higher! Come on over and talk over with
    my web site . Thank you =)

    回复
  25. Touche. Outstanding arguments. Keep up the good work.

    回复
  26. I just could not depart your site prior to suggesting that I
    extremely loved the standard info an individual provide in your guests?
    Is going to be back incessantly to check up on new posts

    回复
  27. These are really wonderful ideas in concerning blogging.
    You have touched some nice factors here. Any way keep
    up wrinting.

    回复
  28. Its like you read my mind! You appear to know a lot
    about this, like you wrote the book in it or something. I think that you could do with a few pics
    to drive the message home a little bit, but instead of that, this is magnificent blog.

    A great read. I will definitely be back.

    回复
  29. It’s going to be finish of mine day, but before ending I am reading
    this fantastic paragraph to improve my know-how.

    回复
  30. I every time used to read piece of writing in news
    papers but now as I am a user of web so from now I am using net for articles or reviews, thanks to web.

    回复
  31. I’ll right away seize your rss feed as I can’t find your email subscription link or newsletter service.
    Do you have any? Please permit me understand in order that
    I may subscribe. Thanks.

    回复
  32. Greetings! Very helpful advice in this particular article!
    It’s the little changes that produce the greatest changes.
    Many thanks for sharing!

    回复
  33. I have learn several good stuff here. Certainly price bookmarking for revisiting.
    I surprise how a lot effort you set to create this type of magnificent informative
    web site.

    回复
  34. Simply desire to say your article is as astonishing.
    The clarity in your submit is simply cool and that i can think you are an expert
    in this subject. Fine together with your permission allow me to grab your feed to stay up to date
    with coming near near post. Thanks one million and please continue the rewarding
    work.

    回复
  35. Hey there I am so delighted I found your web site, I really found you by error, while I was looking
    on Yahoo for something else, Regardless I am here now and would just like to
    say thanks a lot for a remarkable post and a all
    round enjoyable blog (I also love the theme/design), I don’t have time to read it all at the moment but I have
    book-marked it and also added your RSS feeds, so when I have time I will be back to read a great deal more,
    Please do keep up the great work.

    回复
  36. Pretty element of content. I simply stumbled upon your weblog and in accession capital to claim that I get in fact enjoyed
    account your weblog posts. Anyway I’ll be subscribing in your feeds or even I success you get admission to
    persistently rapidly.

    回复
  37. I constantly spent my half an hour to read this website’s articles every day along
    with a cup of coffee.

    回复
  38. This design is incredible! You most certainly know how to keep a reader entertained.

    Between your wit and your videos, I was almost moved to start
    my own blog (well, almost…HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it.
    Too cool!

    回复
  39. I am extremely impressed along with your writing
    talents and also with the layout for your weblog. Is that this a paid topic or did you modify it yourself?
    Either way keep up the excellent quality writing, it’s uncommon to see a great weblog like this
    one today..

    回复
  40. This is a topic which is close to my heart… Many thanks!
    Exactly where are your contact details though?

    回复
  41. Thanks , I’ve just been searching for info about this topic for a
    while and yours is the greatest I’ve found out so far. But, what
    about the bottom line? Are you certain about the supply?

    回复
  42. Have you ever thought about publishing an ebook or guest authoring on other websites?
    I have a blog based on the same topics you discuss
    and would really like to have you share some stories/information.
    I know my viewers would enjoy your work. If you are even remotely interested, feel free to shoot me an e mail.

    回复
  43. You can definitely see your enthusiasm in the work you write.
    The world hopes for even more passionate writers such as you who aren’t afraid
    to mention how they believe. At all times go after your heart.

    回复
  44. memenucom be is mexico

    回复
  45. is tablets suppliers

    d923 i use it is order mail

    回复
  46. be at is online

    a783 acheter is toute securite

    回复
  47. target at is price

    4a82 is lilly preci

    回复
  48. us or canada discount viagra

    回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注