Just a little backup script I wrote which does what I want it to
I bought an external USB hard drive, and thought it was about time I started backing up my data. So, with that in mind, I set about writing a little script to backup my home directory to a folder on the external disk. Here's what I got:
Code:
#! /bin/sh I've still to set it up as a cron job, and I'd like to add a few other directories (/etc, /usr, /boot etc.), but I was quite chuffed it worked at all! Other than scripts for data processing for my thesis, this is the first useful script I've written :) Any suggestions are welcome, but just thought I'd put it out there. |
Cool.
Any suggestions are welcome Not really a suggestion, just regard it as feedback ;-p Code:
#! /bin/sh |
Ah, elegance! That's what I'm looking for...
I've got a few questions about what you've done, if you don't mind? Does set -e mean that if something goes wrong, the script will cease? Code:
case "$1" in Setting a flag from the output of mount was what I'd wanted to do in the first place, but I had no idea how to do it; I suspect that will come in handy in future! Thanks :) Might go home and have a play with new ideas... I'm still struggling with a rename-to-lowercase script too, but that's a FAT32 thing. Thanks again :) |
Ah, elegance! That's what I'm looking for...
No. That's not what you're looking for. You're looking for something that just works. (I mean, I would) Does set -e mean that if something goes wrong, the script will cease? Indeed it does. For more see "man bash", under "set". This bit I don't really understand. Me neither. I just find I've written the scripts when I've woken up. It's rather embarassing. Does this run either cp, tar or rsync? Either. If so, what's it dependent on? When the first commandline arg matches. when does it run cp over tar, for example? When? Never. It *either* copies, tars or rsyncs. I'm still struggling with a rename-to-lowercase script too, but that's a FAT32 thing. There's Bash for POS too. You don't need to install Cygwin for it. |
Quote:
Quote:
Thanks for the clarifications. |
So if I run the script as ./backup_script.sh c, then it'll use cp?
It sez so on the package, so it should. |
All times are GMT -5. The time now is 09:21 PM. |