Лясны жыхар (soko1) wrote in sokolsoft,
Лясны жыхар
soko1
sokolsoft

  • Music:

ossbackup 0.2current

Это current-версия ossbackup.
Всех кто знает английский язык, прошу помочь мне. Проверьте пож-ста правильность написания английских слов (я про комментарии в скрипте), либо предложите свои. Ну и естественно, если найдете погрешности в коде - сообщите. Спасибо.


#!/bin/sh
#author: sokolov alexey <sokolhacker@mail.ru>
#license: bsd 
#name: ossbackup
#version: 0.2current

### OPTIONS ###

# enable and disable options (1 or 0)
compression_enable=1 # compressing files
burn_cd_enable=0 # burning backup from cd
burn_dvd_enable=1 # burning backup from dvd
blank_disk_enable=1 # blanking cd/dvd-disk
ROOT_enable=1
var_enable=1
tmp_enable=1
usr_enable=1
boot_enable=0
home_enable=0
mnt_enable=0

# mount program and options
mount_program="mount -t ufs -o ro"

# umount program and options
umount_program="umount -f"

# compressor program and options
compressor_program="bzip2 -9"

# tar program and options
tar_program="tar -pcf"

# burn cd program and options
burn_cd_program="cdrecord dev=1,0,0 ...?"

# blanking cd program and options
blank_cd_program="cdrecord dev=1,0,0 blank=fast"

# burn dvd program and options
burn_dvd_program="growisofs -dvd-compat -Z /dev/acd0 -J -R"

# blanking dvd program and options
blank_dvd_program="dvd+rw-format /dev/acd0"

# mount point
mount_point="/mnt/work/tmp"

# backup directory
backup_dir="/mnt/work/tmp"

# device
ROOT_device="/dev/ad0s1a"
var_device="/dev/ad0s1d"
tmp_device="/dev/ad0s1e"
usr_device="/dev/ad0s1f"
boot_device=""
etc_device=""
home_device=""
mnt_device=""

# file name
ROOT="ROOT"
var="var"
tmp="tmp"
usr="usr"
boot=""
home=""
mnt=""

### END OPTIONS ###

# burn cd-disk function
burn_cd_func() {
        if [ $blank_disk_enable -ne 0 ]; then
                $blank_cd_program
        fi
        $burn_dvd_program $backup_dir
}

# burn dvd-disk function
burn_dvd_func() {
        if [ $blank_disk_enable -ne 0 ]; then
                $blank_dvd_program
        fi
        $burn_dvd_program $backup_dir
}

if [ $burn_cd_enable -ne 0 ] && [ $burn_dvd_enable -ne 0 ]; then
        echo ""
        echo "#########"
        echo "error in options 'burn_cd_enable' and 'burn_dvd_enable':"
        echo "i need one param: 'burn_cd_enable=1' or 'burn_dvd_enable=1'!"
        echo "#########"
        echo ""
        exit
fi

# ROOT
if [ $ROOT_enable -ne 0 ]; then
        echo $mount_program $ROOT_device":" &&
        $mount_program $ROOT_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $ROOT".tar *:" &&
        $tar_program $backup_dir/$ROOT.tar * &&
        echo "Ok." &&
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# var
if [ $var_enable -ne 0 ]; then
        echo $mount_program $var_device":" &&
        $mount_program $var_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $var".tar *:" &&
        $tar_program $backup_dir/$var.tar * &&
        echo "Ok." &&
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# tmp
if [ $tmp_enable -ne 0 ]; then
        echo $mount_program $tmp_device":" &&
        $mount_program $tmp_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $tmp".tar *:" &&
        $tar_program $backup_dir/$tmp.tar * &&
        echo "Ok." &&
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# usr
if [ $usr_enable -ne 0 ]; then
        echo $mount_program $usr_device":" &&
        $mount_program $usr_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $usr".tar *:" &&
        $tar_program $backup_dir/$usr.tar * &&
        echo "Ok."
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# boot
if [ $boot_enable -ne 0 ]; then
        echo $mount_program $boot_device":" &&
        $mount_program $boot_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $boot".tar *:" &&
        $tar_program $backup_dir/$boot.tar * &&
        echo "Ok."
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# home
if [ $home_enable -ne 0 ]; then
        echo $mount_program $home_device":" &&
        $mount_program $home_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $home".tar *:" &&
        $tar_program $backup_dir/$home.tar * &&
        echo "Ok."
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

# mnt
if [ $mnt_enable -ne 0 ]; then
        echo $mount_program $mnt_device":" &&
        $mount_program $mnt_device $mount_point &&
        echo "Ok." &&
        cd $mount_point &&
        echo $tar_program $mnt".tar *:" &&
        $tar_program $backup_dir/mnt.tar * &&
        echo "Ok."
        cd / &&
        echo $umount_program $mount_point":" &&
        $umount_program $mount_point &&
        echo "Ok."
fi

if [ $compression_enable -ne 0 ]; then
        if [ $ROOT_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$ROOT".tar:" &&
                $compressor_program $backup_dir/$ROOT".tar" &&
                echo "Ok."
        fi
        if [ $var_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$var".tar:" &&
                $compressor_program $backup_dir/$var".tar" &&
                echo "Ok."
        fi
        if [ $tmp_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$tmp".tar:" &&
                $compressor_program $backup_dir/$tmp".tar" &&
                echo "Ok." 
        fi
        if [ $usr_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$usr".tar:" &&
                $compressor_program $backup_dir/$usr".tar" &&
               echo "Ok."
        fi
        if [ $boot_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$boot".tar:" &&
                $compressor_program $backup_dir/$boot".tar" &&
               echo "Ok."
        fi
        if [ $home_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$home".tar:" &&
                $compressor_program $backup_dir/$home".tar" &&
               echo "Ok."
        fi
        if [ $mnt_enable -ne 0 ]; then
                echo $compressor_program $backup_dir/$mnt".tar:" &&
                $compressor_program $backup_dir/$mnt".tar" &&
               echo "Ok."
        fi
fi

if [ $burn_cd_enable -ne 0 ]; then
        burn_cd_func
fi
if [ $burn_dvd_enable -ne 0 ]; then
        burn_dvd_func
fi

echo "Operation is complete!"
  • Post a new comment

    Error

    default userpic
  • 5 comments