#!/bin/sh # # hdbackup - program to backup /hdd3 # version 0.2 # # Copyright (C) 2005 hdluc@yahoo.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # ###################################################################### #DEST=/mnt/usbdisk1/zbackup DEST="$1" DATESTAMP=`date +%Y-%m-%d-%H-%M` FILEPREFIX=backup_SLC3000-hdd3 if [ "$DEST" = "" ] || [ ! -d $DEST ]; then echo "error: please specify valid destination directory" exit 1 fi echo Hd Backup echo backing up /hdd3 to ${DEST}/${DATESTAMP}/ mkdir -p ${DEST}/${DATESTAMP} for i in `ls /hdd3` do if [ -f /hdd3/$i ] && [ "$i" != "swapfile" ]; then echo archiving file $i gzip -c /hdd3/$i > ${DEST}/${DATESTAMP}/${FILEPREFIX}-$i.gz fi if [ -d /hdd3/$i ] && [ "$i" != "Documents" ] && [ "`ls /hdd3/$i`" != "" ]; then echo archiving directory $i tar cf - /hdd3/$i 2>dev/null | gzip - > ${DEST}/${DATESTAMP}/${FILEPREFIX}-$i.tar.gz fi done for i in `ls /hdd3/Documents` do if [ -f /hdd3/Documents/$i ] && [ "$i" != "swapfile" ]; then echo archiving file $i gzip -c /hdd3/Documents/$i > ${DEST}/${DATESTAMP}/${FILEPREFIX}-Documents-$i.gz fi if [ -d /hdd3/Documents/$i ] && [ "`ls /hdd3/Documents/$i`" != "" ]; then echo archiving directory $i tar cf - /hdd3/Documents/$i 2>/dev/null | gzip - > ${DEST}/${DATESTAMP}/${FILEPREFIX}-Documents-$i.tar.gz fi done echo backup done.