LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1020|回复: 4

How to backup your system [Modified from excellent post of this forum]

[复制链接]
发表于 2006-10-4 21:08:05 | 显示全部楼层 |阅读模式
Please note:    The method described here is an updated version of the post on this forum.  I do not intend to translate it into chinese, also I do not think it is necessary.
Please note:    The method described here is an updated version of the post on this forum.  I do not intend to translate it into chinese, also I do not think it is necessary.                                                                     
Please note:    The method described here is an updated version of the post on this forum.  I do not intend to translate it into chinese, also I do not think it is necessary.


                                            
How to Stage IV of Gentoo Linux
Boot your computer using Install CD minimal, and this time folder /proc is empty. Also, due to Grub find stage1 and stage 1.5 in a physical Head/Cylinder/Sector way, if you mount /boot partition the code in MBR will not find stage files any more. So, usually after emerge grub, I unmerge it from my system with /boot partition not mouned. In this way, grub is “fake” unmerged from my box. Forget it forever, don’t touch /boot partition also by mounting it with noauto option. Forget /boot too.
1.  To backup the whole system installed on hdaX, mount target and source partition.
  1. #mount /dev/hdaX /mnt/gentoo
  2. #mount /dev/hdaY /mnt/backup
复制代码
2. To backup Gentoo system with files in /mnt/linux/usr/portage/distfiles excluded.
  1. #cd /mnt/linux
  2. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码
**If you want to burn  disc (CDs), you can split the backup file into smaller ones:
  1. #split -a 1 -b 650m /mnt/backup/Stage4.tar.bz2 /mnt/backup/Stage4.tar.bz2-
复制代码
Several packages with one-alphabet appendix will be generated in backup folder such as
Stage4.tar.bz2-a, Stage4.tar.bz2-b...etc, the maximum size is 650M.

3. To restore the system just combine the packages and unpack it:
Also, boot the computer use Install CD minimal, format target partition.
  1. #mkreiserfs /dev/hdaX
  2. #mount /dev/hdaX /mnt/gentoo
  3. #mount /dev/hdaY /mnt/backup
  4. #cd /mnt/gentoo
  5. #cat /mnt/backup/Stage4.tar.bz2-* | tar -xjvf -
复制代码
If you do not like split backup file, like me, just unpack is enough
  1. #cd /mnt/gentoo
  2. #tar -xjvf /mnt/backup/Stage4.tar.bz2
复制代码
Reboot, now we are back to the future.
Notes:
1. Before backup you should mount all the partition which you want to pack into backup file. For example, if your /usr is a separated partition, you must mount it first.
2. If there are several directories that you do not want to backup such as /usr/portage/distfiles etc, you can write down them in a file called exclude-list (Or any name you like) line by line, one line on folder.
Like this:
  1. # Begin of the example of excluded folder
  2. usr/portage/distfiles
  3. var/tmp/portage
  4. home/yourusername/music
  5. home/yourusername/video
  6. # End of the example of excluded folder
复制代码
Put it into your root folder, then
  1. #tar -cj --exclude-from /mnt/gentoo/root/exclude-list -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码
3. something weird, the result of the following two commands it different, please notice
  1. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
  2. #tar -cj --exclude=usr/portage/distfiles/ -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码
4. Due the the execute speed problem, when unpack there may be some problem
When backup
  1. #tar -cjpivO /mnt/backup/Stage4.tar.bz2 * | split -a 1 -b 650m - /mnt/backup/Stage4.tar.bz2-
复制代码
When restore
  1. #cat /mnt/backup/Stage4.tar.bz2-* | tar -xjvf –
复制代码
Some warning may appeare, just ignore them. If you feel uncomfortable, split them into two commands.
When backup
  1. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
  2. #split -a 1 -b 650m /mnt/backup/Stage4.tar.bz2 /mnt/backup/Stage4.tar.bz2-
复制代码
When restore
  1. #cat /mnt/backup/Stage4.tar.bz2-* >> /mnt/gentoo/Stage4.tar.bz2
  2. #cd /mnt/gentoo/
  3. #tar -xjvpf Stage4.tar.bz2
复制代码
Please note, the target file Stage4.tar.bz2 may be very large, be patient.
5. To place porage tree together disfiles to a separated partition is a VERY good idea. 4GB space is enough. Thus, you do not need to backup, restore and synchronize portage tree again. Backup and restore become like this:
  1. #tar -cjpivf /mnt/backup/Stage4.tar.bz2 *
  2. #tar -xjvpf Stage4.tar.bz2
复制代码
6: Options:
Options for tar
  1. -p: --preserve-permissions
  2. -f: --file
  3. -v: --verbose
  4. -j: --bzip
  5. -z: --gzip/--ungzip
  6. -c: --create
  7. -i: --ignore-zeros
  8. -O: To standout
  9. -x: --extract
  10. -: stdin/stdout
复制代码
Options for split
  1. -a: suffix_length=N
  2. -b: --byte=SIZE [K/M]
复制代码
发表于 2006-10-5 01:59:38 | 显示全部楼层

不是翻译的翻译

如何制作Gentoo Linux的Stage IV(备份)

使用你的Install CD Minimal启动你的电脑,并且这个时候/proc目录是空的。
同样,如果你挂载了/boot分区代码在MBR里,由于Grub会寻找stage1和stage1.5于物理的第一个柱面第一个分区,会导致怎么也找不到stage文件。所以,一般都是(备份完成)之后才安装grub,“我”(原作者,如果没有加以说明,都是指原作者)把它卸载了,并且也没有挂载/boot分区。之后,我的系统里Grub是被“虚假”(因为它的主要作用文件在boot分区里面)地卸载了。
{(--不会翻译--)
记住,不要在不要使用noauto参数建立/boot分区。
把/boot也忘记吧
Forget it forever, don’t touch /boot partition also by mounting it with noauto option. Forget /boot too.
(请高手指明)}

1。为了备份位于hdX面的整个系统,挂载保存(hdY)和源(hdX)分区

  1. #mount /dev/hdX /mnt/gentoo
  2. #mount /dev/hdY /mnt/backup
复制代码

2。排除保存/mnt/linux/usr/portage/distfiles的备份

  1. #cd /mnt/linux
  2. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码

**如果你想保存一个个的盘片(如CD,650MB),你可以分卷备份文件:

  1. #split -a 1 -b 650m /mnt/backup/Stage4.tar.bz2 /mnt/backup/Stage4.tar.bz2-
复制代码

文件被整齐地命名为一个带后续字母表的多个文件,每个文件最大容量为650MB(可以自己自定-b XXXm这个参数,自己可以修改)
Stage4.tar.bz2-a, Stage4.tar.bz2-b...etc, the maximum size is 650M.

3。只要合并文件和还原它们可以还原系统了:
同样是,使用Install CD Minmial启动系统,格式化要还原的分区(hdx)

  1. #mkreiserfs /dev/hdaX
  2. #mount /dev/hdX /mnt/gentoo
  3. #mount /dev/hdY /mnt/backup
  4. #cd /mnt/gentoo
  5. #cat /mnt/backup/Stage4.tar.bz2-* | tar -xjvf -
复制代码

如果你没有分卷,只要还原就足够了。

  1. #cd /mnt/gentoo
  2. #tar -xjvf /mnt/backup/Stage4.tar.bz2
复制代码

重新启动,我们就能回到备份时的环境了。
注意:
1。备份前请挂载全部你需要的分区。比如,如果/usr是独立分区,你就必须要挂载它了。
2。如果你有多个文件夹不想备份,如/usr/portage/distfiles,你可以把它们一行一行地写进一个排除列表里(名字随你定)
就象下面的:

  1. # Begin of the example of excluded folder
  2. usr/portage/distfiles
  3. var/tmp/portage
  4. home/yourusername/music
  5. home/yourusername/video
  6. # End of the example of excluded folder
复制代码

把它放到你的root文件夹里面,再运行备份命令

  1. #tar -cj --exclude-from /mnt/gentoo/root/exclude-list -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码

3。请注意,一下两个不同的命令会输出一些怪异(原文的weird,不太同意,用有趣就足够了)的不同输出

  1. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
  2. #tar -cj --exclude=usr/portage/distfiles/ -pivf /mnt/backup/Stage4.tar.bz2 *
复制代码

4。由于处理的速度问题,可能会引起解压的一些问题
备份时

  1. #tar -cjpivO /mnt/backup/Stage4.tar.bz2 * | split -a 1 -b 650m - /mnt/backup/Stage4.tar.bz2-
复制代码

还原时

  1. #cat /mnt/backup/Stage4.tar.bz2-* | tar -xjvf –
复制代码

一些警告只是说明性的,无须理睬。觉得部署副,就分开两个命令来执行它们吧。
备份时

  1. #tar -cj --exclude=usr/portage/distfiles -pivf /mnt/backup/Stage4.tar.bz2 *
  2. #split -a 1 -b 650m /mnt/backup/Stage4.tar.bz2 /mnt/backup/Stage4.tar.bz2-
复制代码

还原时

  1. #cat /mnt/backup/Stage4.tar.bz2-* >> /mnt/gentoo/Stage4.tar.bz2
  2. #cd /mnt/gentoo/
  3. #tar -xjvpf Stage4.tar.bz2
复制代码

需要注意的是,备份文件可能是很大的,需要耐心等待一下哦:)
5。把porage树目录放到一个独立分区(4GB就足够了)是不错的注意。所以,你只要备份而不用再次同步portage树目录了。备份还原操作如下:

  1. #tar -cjpivf /mnt/backup/Stage4.tar.bz2 *
  2. #tar -xjvpf Stage4.tar.bz2
复制代码

6: 参数设置:
关于Tar的参数

  1. -p: --preserve-permissions
  2. -f: --file
  3. -v: --verbose
  4. -j: --bzip
  5. -z: --gzip/--ungzip
  6. -c: --create
  7. -i: --ignore-zeros
  8. -O: To standout
  9. -x: --extract
  10. -: stdin/stdout
复制代码

关于split的参数

  1. -a: suffix_length=N
  2. -b: --byte=SIZE [K/M]
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-10-5 02:02:20 | 显示全部楼层
补充点:
1。格式化的时候

  1. mkreiserfs /dev/hdX
  2. [code]
  3. 可以改变为自己喜欢的分区类型,自己注意就是:)
  4. [code]
  5. mkfs.(my part format) /dev/hdaX
复制代码

2。全角"("")"里的是我写的一些意见
回复 支持 反对

使用道具 举报

发表于 2006-10-5 11:31:20 | 显示全部楼层
类似这样备份的贴子本坛早有了:http://www.linuxsir.cn/forum.php?mod=viewthread&tid=113082
楼主不妨将英文原帖的链接贴出来,我有点怀疑那是根据hauser在Gentoo论坛发的贴子改的。
回复 支持 反对

使用道具 举报

发表于 2006-10-5 11:39:36 | 显示全部楼层
备份原来就是各有各法,我翻译(不算是啦)不过是来练习语法。。。考试呀。。。
最好的getoo stage4不过于以前getoo论坛里面的一个脚本了。方便又快捷。而且也考虑了/boot问题
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表