ローカルディスクへのバックアップは出来たが、 1日に1回のバックアップでは、最大1日分のデータが失われてしまう。
1時間に1回、差分バックアップを取り、 ロールフォワードできるようにする。
root@xhl:/usr/local/sbin# vi Backup.hr
root@xhl:/usr/local/sbin# cat !$
cat Backup.hr
#!/bin/sh
BACKUPDIR=/mnt/Backup/`hostname`
cd /
VARFILES=`find bin \
boot \
etc \
initrd \
lib \
mnt/home \
opt \
root \
sbin \
selinux \
usr \
-type f -mmin -120 -print `
echo $VARFILES
TGZFILE=varfiles-`date +%H`.tar.gz
tar zcvf $BACKUPDIR/$TGZFILE $VARFILES
root@xhl:/usr/local/sbin#
必要なディレクトリの2時間以内に変更されたファイルをアーカイブする。
root@xhl:/usr/local/sbin# sh -x !$ sh -x Backup.hr + hostname + BACKUPDIR=/mnt/Backup/xhl + cd / + find bin boot etc initrd lib mnt/home opt root sbin selinux usr -type f -mmin -120 -print + VARFILES=etc/inetd.conf etc/rsyncd.conf mnt/home/httpd/cgi-bin/BBS/spam.dat usr/local/sbin/Backup.hr + echo etc/inetd.conf etc/rsyncd.conf mnt/home/httpd/cgi-bin/BBS/spam.dat usr/local/sbin/Backup.hr etc/inetd.conf etc/rsyncd.conf mnt/home/httpd/cgi-bin/BBS/spam.dat usr/local/sbin/Backup.hr + date +%H + TGZFILE=varfiles-15.tar.gz + tar zcvf /mnt/Backup/xhl/varfiles-15.tar.gz etc/inetd.conf etc/rsyncd.conf mnt/home/httpd/cgi-bin/BBS/spam.dat usr/local/sbin/Backup.hr etc/inetd.conf etc/rsyncd.conf mnt/home/httpd/cgi-bin/BBS/spam.dat usr/local/sbin/Backup.hr root@xhl:/usr/local/sbin# ls -l /mnt/Backup/xhl/ total 12 -rw-r--r-- 1 root root 1488 Nov 1 15:23 varfiles-15.tar.gz drwxr-xr-x 2 root root 4096 Oct 31 22:04 xhl.1410 drwxr-xr-x 2 root root 4096 Nov 1 03:06 xhl.1411 root@xhl:/usr/local/sbin# tar ztvf /mnt/Backup/xhl/varfiles-15.tar.gz -rw-r--r-- root/root 1252 2014-11-01 14:58 etc/inetd.conf -rw-r--r-- root/root 175 2014-11-01 14:54 etc/rsyncd.conf -rw-rw-r-- guest/www-data 806 2014-11-01 15:23 mnt/home/httpd/cgi-bin/BBS/spam.dat -rw-r--r-- root/staff 273 2014-11-01 15:22 usr/local/sbin/Backup.hr root@xhl:/usr/local/sbin#OK
root@xhl:/usr/local/sbin# crontab -e : : crontab: installing new crontab root@xhl:/usr/local/sbin# crontab -l | grep Backup.hr 16 * * * * nice /bin/sh /usr/local/sbin/Backup.hr 2>/dev/null 1>/dev/null root@xhl:/usr/local/sbin#
|
|
← ローカルバックアップ |
ハックの記録 LinkStation/玄箱 をハックしよう |
→ リモートバックアップ |
Copyright (C) 2003-2014 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市