Shell/Bash在线运行

运行结果
教程手册
代码仓库
极速运行
终端运行
图形+终端

                        
以下是用户最新保存的代码
game color 发布于:2023-12-04 17:14 一键sh安装脚本 发布于:2023-12-02 13:59 打印等边三角形 发布于:2023-11-28 20:00 shell计算器 发布于:2023-11-22 17:22 重启执行docker 发布于:2023-11-21 10:57 测试数据局 发布于:2023-10-19 17:06 查询被封禁ip 发布于:2023-09-19 16:37 shell减法函数 发布于:2023-09-13 10:57 centos7测试tomcat服务是否正常运行 发布于:2023-09-13 10:25 shell-study 发布于:2023-09-06 15:06 just for shell script learn 发布于:2023-09-01 09:34 测试Shell参数传递 发布于:2023-08-24 11:27 对cdh6进行自动化安装 发布于:2023-08-23 10:10 安装zookeeper 发布于:2023-08-14 18:32 安装mongo 发布于:2023-08-11 17:40 容器安装mysql 发布于:2023-08-04 15:19 最后的最后把它搞定 发布于:2023-08-03 14:32 shell测试 发布于:2023-08-01 16:07 Shell 代码验证 发布于:2023-07-24 15:25 shell测试程序 发布于:2023-07-23 22:31 shell函数5-4 while循环 发布于:2023-07-20 10:56 shell的demo 发布于:2023-07-17 23:14 # linux 初学者 发布于:2023-08-24 15:02 shell 在线脚本 1 发布于:2023-07-12 22:16 简单的计算器实现 发布于:2023-07-11 17:17 手机号码正则验证 发布于:2023-08-07 16:20 指定关闭或打开端口号 发布于:2023-07-07 16:14 #!/bin/bash a="hello,world,nice,to,meet,you" #要将$a分割开,先存储旧的分隔符 OLD_IFS="$IFS" #设置分隔符 IFS="," #如下会自动分隔 arr=($a) #恢复原来的分隔符 IFS="$OLD_IFS" function func1(){ echo $@ } #遍历数组 for s in ${arr[@]} do func1 "$s" done echo "完成" 发布于:2023-07-04 14:17 批量增加用户打印 发布于:2023-06-12 13:41 ##10num求最值平均值 发布于:2023-06-12 16:12 测试Jenkins 发布于:2023-06-07 14:02 九九乘法表 发布于:2023-06-07 10:37 case判断 发布于:2023-06-07 10:13 这是一个测试代码 发布于:2023-06-07 09:25 测试shell 发布于:2023-05-29 18:53 ## shell流程控制语句 发布于:2023-05-29 14:46 shell函数 发布于:2023-05-29 11:32 prinf格式化 发布于:2023-05-29 11:15 Break语句 发布于:2023-05-29 11:11 ## echo输出命令 发布于:2023-05-29 10:23 ## 字符串运算符 发布于:2023-05-26 15:55 ## 获取数组的所有元素 ## 获取数组的长度 发布于:2023-05-26 15:19 ## 读取数组 ## 关联数组 发布于:2023-05-26 15:10 编写shell脚本,输出0 - 500 这几个数字中,是7倍数的数字,比如7, 14, 21....,不包括0 发布于:2023-05-25 16:04 计算1-100之间的所有奇数和 发布于:2023-05-25 14:10 # shell多行注释 发布于:2023-05-25 11:59 # Shell数组 ## 定义数组 ## 读取数组 ## 获取数组的长度 发布于:2023-05-25 11:57 # Shell字符串 ## 拼接字符串 ## 提取子字符串 ## 查找子字符串 发布于:2023-05-25 11:49 删除变量简介 发布于:2023-05-25 11:31 Shell变量1 发布于:2023-05-25 11:27 [更多]
显示目录

restore 命令-恢复dump操作的数据



restore 命令

restore 命令是 dump 命令的配套命令,dump 命令是用来备份分区和数据的,而 restore 命令是用来恢复数据的。

基本格式

[root@localhost ~]# restore [模式选项] [-f]

-f 选项用于指定备份文件的文件名;restore 命令常用的模式有以下 4 种,这 4 种模式不能混用:

-C: 比较备份数据和实际数据的变化。
实际数据中现有数据发生变化,这个选项能检测到这个变化。
但实际数据中新增了数据,这个选项不能检测到变化的。
-i: 进入交互模式,手工选择需要恢复的文件;
-t: 查看模式,用于查看备份文件中拥有哪些数据;
-r: 还原模式,用于数据还原;

示例

比较备份数据和实际数据的变化。

这里大家需要注意,数据比较只有在原有数据减少或发生变化时才能检测到变化,而新增的数据是不会被检测到的。命令如下:

[root@localhost ~]# touch /boot/abc
#在/boot/目录中新建abc文件
[root@localhost ~]# restore -C -f /root/boot.bak.bz2
Dump tape is compressed.
Dump date:Wed Jun 5 08:20:02 2013
Dumped from:the epoch
Level 0 dump of /boot on localhost:/dev/sda1
Label:none
filesys = /boot
#restore检测,没发现任何变化(备份数据在备份时没有abc文件,restore命令是不能识别新建文件的)
[root@localhost ~]# mv /boot/vmlinuz-2.6.32-279.el6.i686 /boot/vmlinuz-2.6.32-279.el6.i686.bak
#把/boot/目录中的内核镜像文件改一个名字
[root@localhost ~]# restore -C -f /root/boot.bak.bz2
Dump tape is compressed.
Dump date:Wed Jun 5 08:20:02 2013
Dumped from:the epoch
Level 0 dump of /boot on localhost:/dev/sda1
Label:none
filesys = /boot
restore:unable to stat ./vmlinuz-2.6.32-279.el6.i686:No such file or directory Some files were modified! 1 compare errors
#restore发现内核镜像文件丢失

这个实验比较危险,一定要记得把内核镜像文件的名字改回来,否则一旦重启,系统就会无法正常启动。

[root@localhost ~]# mv/boot/vmlinuz-2.6.32-279.el6.i686.bak/boot/vmlinuz2.6.32-279.el6.i686

查看模式

这种模式比较简单,就是查看备份文件中到底包含什么内容。命令如下:

[root@localhost ~]# restore -t -f boot.bak.bz2
Dump tape is compressed.
#备份数据是压缩的
Dump date:Wed Jun 5 08:20:02 2013
#数据备份时间
Dumped from:the epoch
Level 0 dump of /boot on localhost:/dev/sda1
#备份等级
Label:none
#分区的卷标,没有设定卷标
2.
11 ./lost+found
12 ./grub
24 ./grub/grub.conf
13 ./grub/splash.xpm.gz
…省略部分输出…

还原模式

restore 命令的还原模式既可以用于还原整个分区,也可以用于还原文件或目录。命令格式是一样的,不过要注意,如果要还原增量备份的数据,则一定要先还原完全备份的数据。命令如下:

#还原boot.bak.bz2分区备份
#先还原完全备份的数据
[root@localhost ~]# mkdir boot.test
#建立准备解压缩的目录。当然,如果这个目录是我新建的分区,就可以直接把数据恢复到分区中
[root@localhost ~]# cd boot.test/
#进入解压缩目录
[root@localhost boot.test]# restore -r -f /root/boot.bak.bz2
Dump tape is compressed.
#备份数据是压缩数据
#解压缩
[root@localhost boot.test]#ll
#查看一下解压缩的文件
总用量21300
-rw-r--r--. 1 root root 106611 6月 22 2012 config-2.6.32-279.el6.i686 drwxr-xr-x. 3 root root 4096 4 月 10 21:47 efi drwxr-xr-x. 2 root root 4096 4 月 10 21:49 grub
-rw-r--r--. 1 root root 14708399 4 月 10 21:49 initrara£s-2.6.32-279.el6.i686.img
drwx------. 2 root root 4096 4 月 10 21:44 lost+found
-rw-------. 1 root root 47504 6 月 5 09:44 restoresymtable
-rw-r--r--. 1 root root 175903 6 月 22 2012 symvers-2.6.32-279.el6.i686.gz
-rw-r--r--. 1 root root 1846041 6 月 22 2012 System.map-2.6.32-279.el6.i686
-rw-r--r--. 1 root root 1048576 6 月 5 02:38 test
-rwxr-xr-x. 1 root root 3856608 6 月 22 2012 vmlinuz-2.6.32-279.el6.i686
#再还原增量备份的数据
[root@localhost boot.test]# restore -r -f /root/boot.bakl.bz2
Dump tape is compressed.
#恢复增量备份的数据
[root@localhost boot.test]# ll
总用量21328
-rw-r--r--. 1 root root 106611 6 月 22 2012 config-2.6.32-279.el6.i686
drwxr-xr-x. 3 root root 4096 4 月 10 21:47 efi
drwxr-xr-x. 2 root root 4096 4 月 10 21:49 grub
-rw-r--r--. 1 root root 14708399 4 月 10 21:49 initramfs-2.6.32-279.eX6.i686.img
-rw-r--r--. 1 root root 24772 6 月 5 08:20 install. log
#增量备份的install.log文件被恢复了
drwx------. 2 root root 4096 4 月 10 21:44 lost+found
-rw-------. 1 root root 47552 6 月 5 09:57 restoresymtable
-rw-r--r--. 1 root root 175903 6 月 22 2012 symvers-2.6.32-279.el6.i686.gz
-rw-r--r--. 1 root root 1846041 6 月 22 2012 System.map-2.6.32-279.el6.i686
-rw-r--r--. 1 root root 1048576 6 月 5 02:38 test
-rwxr-xr-x. 1 root root 3856608 6月  22 2012 vmlinuz-2.6.32-279.el6.i686

还原/etc/目录的备份etc.dump.bz2,其还原方法完全一样。命令如下:

[root@localhost ~]# restore -r -f etc.dump.bz2
Dump tape is compressed.
#还原etc.dump.bz2备份
[root@localhost ~]# ll -d /root/etc
drwxr-xr-x.103 root root 12288 6月 5 07:45 /root/etc
#在root下生成了etc目录,里面的数据和/etc/目录中的数据完全一致
由JSRUN为你提供的Shell/Bash在线运行、在线编译工具
        JSRUN提供的Shell/Bash 在线运行,Shell/Bash 在线运行工具,基于linux操作系统环境提供线上编译和线上运行,具有运行快速,运行结果与常用开发、生产环境保持一致的特点。