Shell/Bash在线运行

所属目录
点击了解高性能代码运行API
运行结果
教程手册
代码仓库
极速运行
终端运行
图形+终端

                        
以下是用户最新保存的代码
shell脚本学习 发布于:2024-03-07 16:03 bash zndf判断 发布于:2024-03-06 10:23 #### 实验1.1验证输入密码脚本 发布于:2024-03-05 20:16 rm -f测试程序 发布于:2024-03-05 17:40 shell保存简悦导出的markdown文件 发布于:2024-03-03 15:22 grep 三个命令递进组合 发布于:2024-02-28 17:41 if+单大括号 发布于:2024-02-22 15:18 cp拷贝文件 发布于:2024-02-22 14:48 shell脚本编辑学习 发布于:2024-02-20 09:24 shell脚本 发布于:2024-01-26 20:43 学习shell 发布于:2024-01-23 17:31 此脚本检测ChIP-seq样本是否input和IP匹配 发布于:2024-01-17 13:38 一键运行脚本 发布于:2024-01-13 21:37 单点进程与图形声音进程 发布于:2024-01-12 14:58 随机生成10个不相同的整 发布于:2023-12-08 10:18 game color 发布于:2023-12-04 20:01 一键sh安装脚本 发布于:2023-12-15 18:53 打印等边三角形 发布于: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 [更多]
显示目录

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



学习嵌入式的绝佳套件,esp8266开源小电视成品,比自己去买开发板+屏幕还要便宜,省去了焊接不当搞坏的风险。 蜂鸣版+触控升级仅36元,更强的硬件、价格全网最低。

点击购买 固件广场

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操作系统环境提供线上编译和线上运行,具有运行快速,运行结果与常用开发、生产环境保持一致的特点。
yout