Sao lưu & phục hồiKhâu tối cần thiết đối với người quản trị.. Nên được thực hiện tự động hóa scripting+scheduler Các dạng backup thông dụng: Full backup Incremental backup Network
Trang 1Âu Bửu Long
Trang 2Sao lưu & phục hồi
Khâu tối cần thiết đối với người quản trị.
Nên được thực hiện tự động hóa (scripting+scheduler)
Các dạng backup thông dụng:
Full backup
Incremental backup
Network backup
Dump backup
Trang 3Sao lưu & phục hồi
Các tiêu chí backup & restore:
Tính quan trọng của dữ liệu
Lượng dữ liệu
Chi phí dành cho sao lưu
Thời gian dành cho sao lưu
Dữ liệu nên được backup nhiều lần và đặt ở nhiều nơi.
Trang 4Sao lưu…
Công cụ sao lưu tông dụng trong linux:
Text User Interface(tui):
tar
cpio
ls | cpio -ov > directory.cpio
find -print -depth | cpio -ov > tree.cpio
cpio -iv < directory.cpio
cpio -idv < tree.cpio
Trang 5Sao lưu
dd
dd if=/dev/hdx of=/path/to/image
dd if=/dev/zero of=/path/to/image bs=blocksize count=numberofblock
dd if=/path/to/image of=/dev/hdx
rsync
rsync [options] sources dest
source&desc: user@host:port/filename
rsync -r /home backup@192.168.1.12:/home/backup/ bkupdata
Trang 6#
# creates backups of essential files
#
DATA="/home /root /usr/local/httpd"
CONFIG="/etc /var/lib /var/named"
LIST="/tmp/backlist_$$.txt"
#
set $(date)
#
if test "$1" = "Sun" ; then
# weekly a full backup of all data and config settings:
#
tar cfz "/mnt/backup/data/data_full_$6-$2-$3.tgz" $DATA
rm -f /mnt/backup/data/data_diff*
#
tar cfz "/mnt/backup/config/config_full_$6-$2-$3.tgz" $CONFIG
rm -f /mnt/backup/config/config_diff*
Trang 7 else
# incremental backup:
#
find $DATA -depth -type f \( -ctime -1 -o -mtime -1
\) -print > $LIST
tar cfzT
"/mnt/backup/data/data_diff_$6-$2-$3.tgz" "$LIST"
rm -f "$LIST"
#
find $CONFIG depth type f \( ctime 1 o
-mtime -1 \) -print > $LIST
tar cfzT
"/mnt/backup/config/config_diff_$6-$2-$3.tgz" "$LIST"
rm -f "$LIST"
fi
#
Trang 8Sao lưu
Graphical User Interface(GUI):
Keep
sbackup
fwbackup
Trang 9Bài tập
Sửa file script trên để có thể thực hiện công việc backup tất cả các file trong thư mục /var/www
vào thư mục ~/backup
Yêu cầu: thực hiện công việc incremental backup mỗi ngày, riêng ngày thứ 5 thực hiệc công việc full backup lúc 24h:00
Script sẽ đọc file cấu hình ~/backup/bkup.conf,
là file text với các tùy chọn có dạng key value
sau:
full: true or false: luôn thực hiện full backup
clear: true or false: khi thực hiện full bkup, xóa các file incr bakup trước
disabled: true or false: vô hiệu hóa script backup
Trang 10Quản lý người dùng
trong đó có 1 nhóm chính.
/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow
Trang 11Quản lý người dùng
useradd
usermod
userdel
passwd
groupadd
groupmod
groupdel
Trang 12Bài tập
Trang 13POST và OS
LILO
GRUB
Trang 14GRUB bootloader
Được cài đặt trong /boot/grub
File cấu hình: /boot/grub/menu.lst với các tham số chính
default
timeout
title
makeactive
chainloader
kernel
initrd
password
Trang 15Cài đặt lại grub:
sudo grub
find /boot/grub/stage1
root (hd?,?)
setup (hd?)
quit