Thursday, October 4, 2007

Automatic Backup Data To TAPE

If you want run scheduler for backup your data from disk to tape, please follow its steps below. Make sure your tape drive(s) is installed properly.

Check with command below assume that your tape drive(s) is /dev/st0 or /dev/nst0 or /dev/tape. Before run this command please insert tape into drive.

[root@intranet~]# mt -f /dev/st0 status

SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 512 bytes. Density code 0x40 (DLT1 40 GB, or Ultrium).
Soft error count since last status=0
General status bits on (41010000):
BOT ONLINE IM_REP_EN


If your tape drive is OK then please create script to backup your data and place into one location or path.

# vi backup.sh

#!/bin/sh
###################################
# Konang Supian #
# 04 Okt 2007 MDGTI #
###################################
# File naming : day.month.year
suffix=$(date +%d.%m.%Y)
# Path to save file
echo Creating New Directory ....
dir=/usr/backup
dir1=$dir/$suffix
/bin/mkdir -p $dir1
# Daily Backup DB Mysql
echo Compressing DB MySQL ....
/bin/tar -zcf $dir1/mysql.$suffix.tar.gz /var/lib/mysql
# Daily Backup Source Program
echo Compressing Source Program ....
/bin/tar -zcf $dir1/source.$suffix.tar.gz /aplikasi
# Daily Backup DNS Zone
echo Compressing DNS Zone Data ....
/bin/tar -zcf $dir1/named.$suffix.tar.gz /var/named/chroot/var/named
# Writes to TAPE
echo FULL BACUP TO TAPE ....
/bin/tar cvf /dev/st0 $dir
echo ------------
echo FINISH REK
echo ------------



Edit your crontab :

# crontab -e

# Backup Harian DB Mysql, Source Program & DNS - pukul 05:00 pagi
0 5 * * * /root/backup.sh

[LIST TAPE]
#
/bin/tar -tvf /dev/st0

Example:
[root@intranet~]# tar -tvf /dev/st0

drwxr-xr-x root/root 0 2007-10-04 10:09:16 usr/backup/04.10.2007/
-rw-r--r-- root/root 12409437 2007-10-04 10:36:25 usr/backup/04.10.2007/mysql.04.10.2007.tar.gz
-rw-r--r-- root/root 228892698 2007-10-04 10:36:46 usr/backup/04.10.2007/source.04.10.2007.tar.gz


[EXTRACT TAPE]
# /bin/tar -xvf /dev/st0

[REWIND & EJECT TAPE]
# /bin/mt -f /dev/st0 rewoffl

Search Linux Resources