Скрипт дампа системы

bash, perl, python и прочие интерпретируемые скрипты

Moderator: Gen1us2k

Post Reply
User avatar
Raven
Бородатый сис
Бородатый сис
Posts: 2791
Joined: 03 Mar 2010, 15:12
ОС: RHEL 8
Location: Из серверной

Скрипт дампа системы

Post by Raven » 31 Mar 2010, 11:05

Собственно вот:

Code: Select all

#!/bin/sh
# Enter info:
e_mail="admin@domain.kg"
backup_date="`date +%d-%m-%Y`"

# Path to command
mount="/sbin/mount"
umount="/sbin/umount"
dump="/sbin/dump"
# Path to programm
massive="/mnt/usb"


# Mount usb
${mount} /dev/sdc0 ${massive}

# Create dump slice
${dump} -0ua -L -f ${massive}/dump_root.img /dev/sda1
${dump} -0ua -L -f ${massive}/dump_usr.img /dev/sda5
${dump} -0ua -L -f ${massive}/dump_var.img /dev/sda7

# If file exists
if [ -f $massive/dump_root.img ]
then dump1="Image dump_root.img was created";
else echo "Image dump_root.img was not created, please see this dump!" | mail -s "!!ERROR Dump!!" ${e_mail}
exit 2;
fi

if [ -f $massive/dump_usr.img ]
then dump2="Image dump_usr.img was created";
else echo "Image dump_usr.img was not created, please see this dump!" | mail -s "!!ERROR Dump!!" ${e_mail}
exit 2;
fi

if [ -f $massive/dump_var.img ]
then dump3="Image dump_var.img was created";
else echo "Image dump_var.img was not created, please see this dump!" | mail -s "!!ERROR Dump!!" ${e_mail}
exit 2;
fi

# Umount usb massive
${umount} ${massive}

# Mail to me
echo "
${dump1}
${dump2}
${dump3}
" | mail -s dump_${backup_date} ${e_mail}
Создает img образы указанных разделов вашего диска.
Я не злопамятный, я просто часто ковыряю логи
Post Reply