Shell Scripting FTW
Today I made a nice little handy script that automates my (CD) backups for future cron job use.
Still requires more work so that it only outputs relevant info in cronjob logs.
#!/bin/sh
master()
{
    tmp=${backup_dir}-`date +%Y%m%d`.iso
    if [ -f $tmp ]
    then
        mv $tmp old.${tmp}
    else
        mkisofs -v -J -V backup -A '' -N -sysid '' -o $tmp $backup_dir
    fi
}
archive()
{
    list="/boot /etc /root /tmp /var"
    other="/usr/home"
    for index in $list
    do
        tar cfv ${backup_dir}/`basename ${index}`.tgz $index
    done
    tar cfvz ${backup_dir}/usr-home.tgz /usr/home/
}
clean()
{
    for blah in `ls ${backup_dir}`
    do
        rm -rf $blah
    done
}
backup_dir="/u1/backup"
clean
archive
master
<insert usual software disclamer here>
Comming soon: Howto setup cron :)
 
No comments:
Post a Comment