linux - clonezilla 将日志文件复制到 USB 设备

标签 linux shell logging clonezilla

我想使用clonezilla-live USB 棒创建/恢复完全无人值守的系统镜像。到目前为止,无人值守的备份/恢复工作正常。我只需插入棒,启动电脑,工作完成后电脑就会关闭。

现在我需要确认备份/恢复是否成功。 为此,我想执行一个 shell 脚本,在工作完成后将日志文件复制到 USB 棒上的其他分区的特定文件中。

我尝试在 syslinux.cfg 中将脚本作为 postrun-method 执行,但这总是导致错误。 此外,我用 drbl-ocs 尝试过,但我不确定我是否做对了。

这是我要执行的 shell 脚本:

#!/bin/sh

#############
/opt/drbl/sbin/ocs-sr -q2 -j2 -z1p -i 4096 -p true savedisk img sda
#############
dir=/home/partimag/logs/

time=$(date +"%H-%M-%S")    # current time
i=$(ls -l $dir | wc -l)     # index

# create log-directory if it didn't exist
if [ ! -e $dir ] 
then
    sudo mkdir $dir
fi

# create new log-directory (
sudo mkdir $dir/$i"_"@$time

# copy all log-files to the created directory
sudo cp /var/log/* $dir/$i"_"@$time

# shut-down the machine
sudo shutdown -h now

第一条指令(在 shebang 之后)是我尝试使用 drbl-ocs,但我并不真正知道这是什么。我相信它是另一个可以处理 shell 脚本的解释器..我说得对吗?

这是我使用的 syslinux.cfg:

append initrd=/live/initrd.img boot=live username=user config quiet noswap     edd=on nomodeset nodmraid noeject locales=en_US.UTF-8 keyboard-layouts=NONE ocs_prerun="mount /dev/sdb2 /mnt/" ocs_prerun1="mount --bind /mnt/ /home/partimag/" ocs_live_run="/lib/live/mount/medium/syslinux/clonezilla.sh" ocs_live_extra_param="" ocs_live_batch="yes" vga=788 ip=  nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1

请帮忙! 谢谢:)

最佳答案

好的,明白了:)

唯一要做的就是在 ocs_live_run 方法前面添加解释器。

现在 syslinux.cfg 看起来像这样:

append initrd=/live/initrd.img boot=live username=user config quiet noswap edd=on nomodeset nodmraid noeject locales=en_US.UTF-8 keyboard-layouts=NONE ocs_prerun="mount /dev/sdb2 /mnt/" ocs_prerun1="mount --bind /mnt/ /home/partimag/" ocs_live_run="bash /lib/live/mount/medium/syslinux/clonezilla.sh" ocs_live_extra_param="" ocs_live_batch="yes" vga=788 ip=  nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1

如果这对您有用,请评价:)

关于linux - clonezilla 将日志文件复制到 USB 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29166683/

相关文章:

c++ - Pantheios 在 C++ 中设置显示级别

Java 加密日志

linux - 如何从包含日期的多个文件中提取日期?

c++ - PROT_EXEcflags在 mprotect 中有什么作用?

linux - 如何从脚本/手动或通过管道调用编辑和执行命令

python - 无法在 django shell python 中导入 readline

c# - 自动登录进入c#项目中的每个方法

python - 将 Bash 脚本的剩余 `n-2` 个参数提供给调用的命令

linux - 如何修复 sed 无效命令代码'?

shell - BigQuery命令无法从Oozie工作流程运行