I'm trying to set[ ]up a simple backup script but yet I'm finding myself struggling because no matter how much I google and read, can't seem to find what I am looking for.
So what I am wanting to do is mount my external USB drive, rsync data to it, place a time stamp into a log file, then unmount the drive. I don't want it mounted all the time as I may want to yank it out when I need it, not worry about logging into my system to unmount it. So far I've come up with this and it's not working.
Any help would be greatly appreciated.
So what I am wanting to do is mount my external USB drive, rsync data to it, place a time stamp into a log file, then unmount the drive. I don't want it mounted all the time as I may want to yank it out when I need it, not worry about logging into my system to unmount it. So far I've come up with this and it's not working.
Code:
#!/bin/bash
if [ -f /dev/da0p1 ] ; then
mount /dev/da0p1 /backup
rsync -a --delete /data/folder /backup/folder
date > /home/user/backup/file.log
umount /backup
else
quit
fi
Any help would be greatly appreciated.