Hi all
I am just learning bash wrote my first script. It's purpose is to perform a daily backup of hard drive to a usb stick. I appears to be working ok, but would appreciate any insight, comments or suggestions as to how I might improve it. If possible, please don't post actual code, just point me in the right direction or else I'll be to lazy to learn lol!. Thanks all
I am just learning bash wrote my first script. It's purpose is to perform a daily backup of hard drive to a usb stick. I appears to be working ok, but would appreciate any insight, comments or suggestions as to how I might improve it. If possible, please don't post actual code, just point me in the right direction or else I'll be to lazy to learn lol!. Thanks all
Code:
# Test if usb drive is mounted
#
TESTDIR="/media/sparkz"
if
[ -d "$TESTDIR" ]
then
# echo "already mounted"
# ls -al /media
rsync -a -v -i --progress -H -s \
--delete \
--delete-excluded \
--exclude-from=/home/sparkz/Backup/exclude_list.txt \
--log-file=/var/log/rsync.log / /media/
umount /dev/sdb1
else
mount /dev/sdb1 /media/
rsync -a -v -i --progress -H -s \
--delete \
--delete-excluded \
--exclude-from=/home/sparkz/Backup/exclude_list.txt \
--log-file=/var/log/rsync.log / /media/
# echo "now mounted"
# ls -al /media
umount /dev/sdb1
fi
#
# rsync exclude list used by full system backup
#
dev
lost+found
media
mnt
proc
run
sys
tmp
var
.readahead
*/lost+found/*
*/.readahead/*
*/Trash/*
*~*
*.backup
*.bak
*.cache
*.swp
*.tmp
*.temp