600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > Linux系统学习第四章:文件压缩 打包与备份(二)备份与还原

Linux系统学习第四章:文件压缩 打包与备份(二)备份与还原

时间:2021-11-22 20:20:07

相关推荐

Linux系统学习第四章:文件压缩 打包与备份(二)备份与还原

一、备份:dump

(1)dump -S 设备名 :显示需要备份的设备所在分区所需要的最小的容量

1 [root@localhost php]# dump -S /dev/sda22 4710404096

(2)dump -W 查看所有分区是否备份过(或者说在/etc/fstab这个文件中 是否有相应的备份的记录)

1 [root@localhost php]# dump -W2 Last dump(s) done (Dump '>' file systems):3 > /dev/sda2(/) Last dump: never4 > /dev/sda3( /home) Last dump: never5 > /dev/sda1( /boot) Last dump: never

(3) dump [-uvj] [-level] [-f] 备份后的文件名 要备份的数据

参数说明:

-u 将备份的时间记录到/etc/dumpdates文件中

-v 显示备份进度

-j 使用bzip2进行压缩

-level 用0-9代替这个level代表备份的等级

-f 后面接备份的文件名

1 [root@localhost php]# dump -0uvj -f /root/home_1205.dump /home 2 DUMP: Date of this level 0 dump: Wed Dec 5 15:51:14 3 DUMP: Dumping /dev/sda3 (/home) to /root/home_1205.dump 4 DUMP: Excluding inode 8 (journal inode) from dump 5 DUMP: Excluding inode 7 (resize inode) from dump 6 ……(#此处省略备份过程中的相关数据) 7 DUMP: DUMP IS DONE 8 [root@localhost php]# cd /root 9 [root@localhost ~]# ls10 anaconda-ks.cfg Desktop home_1205.dump install.log install.log.syslog

我们再来测试一下 dump -W这个命令查看一下:

1 [root@localhost ~]# dump -W 2 Last dump(s) done (Dump '>' file systems):3 > /dev/sda2(/) Last dump: never4 /dev/sda3( /home) Last dump: Level 0, Date Wed Dec 5 15:51:14 5 > /dev/sda1( /boot) Last dump: never

因为刚才备份过一次了,所以就有相应的记录了

二、还原:restore

(1)restore -t -f 备份文件

查看备份文件的相关信息

1 [root@localhost ~]# restore -t -f home_1205.dump 2 Dump tape is compressed. 3 Dump date: Wed Dec 5 15:51:14 4 Dumped from: the epoch 5 Level 0 dump of /home on localhost.localdomain:/dev/sda3 6 Label: /home 72. 8 11./lost+found 932001./admin10……(此处省略其他文件)

(2)restore -C -f 备份文件

查看备份文件与备份所在的目录的现状的差异

1 [root@localhost ~]# restore -C -f home_1205.dump 2 Dump date: Wed Dec 5 16:04:53 3 Dumped from: the epoch4 Level 0 dump of /home on localhost.localdomain:/dev/sda35 Label: /home6 filesys = /home

(3)restore -i -f 备份文件

进入互动模式

用help调出所有互动模式下可以使用的命令:

1 [root@localhost ~]# restore -i -f home_1205.dump 2 restore > help 3 Available commands are: 4 ls [arg] - list directory 5 cd arg - change directory 6 pwd - print current directory 7 add [arg] - add `arg' to list of files to be extracted 8 delete [arg] - delete `arg' from list of files to be extracted 9 extract - extract requested files10 setmodes - set modes of requested directories11 quit - immediately exit program12 what - list dump header information13 verbose - toggle verbose flag (useful with ``ls'')14 prompt - toggle the prompt display15 help or `?' - print this list16 If no `arg' is supplied, the current directory is used17 restore > ls18 .:19 admin/dev/ ec_admin/ lost+found/ test/

(4)restore -r -f 备份文件

还原整个文件系统:

1 [root@localhost ~]# restore -r -f home_1205.dump 2 restore: ./lost+found: File exists3 restore: ./admin: File exists4 restore: ./admin/.mozilla: File exists5 restore: ./admin/.mozilla/extensions: File exists6 restore: ./admin/.mozilla/plugins: File exists7 restore: ./admin/.kde: File exists8 restore: ./admin/.kde/Autostart: File exists9 ……(省略其他文件)

三、备份文件或磁盘:dd

语法:dd if=被备份的文件 of=备份文件 bs=block块大小 count=block数量

1 [root@localhost ~]# dd if=/etc/passwd of=/home/passwd2 3+1 records in3 3+1 records out4 2028 bytes (2.0 kB) copied, 0.000217227 seconds, 9.3 MB/s5 [root@localhost ~]# cd /home/6 [root@localhost home]# ls7 360 admin dev ec_admin lost+found passwd test

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。