|
From: Keith G. Robertson-T. <dum...@sl...> - 2009-01-12 11:11:25
|
Verily I say unto thee, that Keith G. Robertson-Turner spake thusly:
I shouldn't write these scripts late at night :)
I just realised that "next_set" will be undefined (below) if "level" is
anything other than 6.
> #!/bin/bash
>
> # /mnt/backup must be available and defined in /etc/fstab
> mount /mnt/backup
>
> mypc=$(hostname)
> backup_path="/mnt/backup/${mypc}/sets"
>
> mkdir -p "${backup_path}"/{1,2}/dumps/{0,1,2,3,4,5,6}
>
> if [ ! -e "${backup_path}/current" ]
> then
> echo 1 > "${backup_path}/current"
> fi
>
> level=$(expr $(date +%u) - 1)
>
> read current_set < "${backup_path}/current"
> if [ $level -eq 6 ]
> then
> if [ $current_set -eq 1 ]
> then
> next_set=2
> else
> next_set=1
> fi
### correction
else
next_set=$current_set
> fi
>
> uid=$(date +%Y%m%d)
>
> dump -${level}u -z \
> -f "${backup_path}/${current_set}/dumps/${level}/${mypc}-${uid}.dump" /
>
> rm -f "${backup_path}/current"
> echo $next_set > "${backup_path}/current"
>
> umount /mnt/backup
>
> exit 0
> ###
It could probably do with some more error checking too.
--
Regards,
Keith G. Robertson-Turner
|