This is my first attempt at a shell script, and honestly I'm not even sure if its a shell or a bash.
Don't penalise me too much, I'm learning and I'm going at a slow pace. Below is my effort at a shell script that transfers files using another perl module written by a much talented author, Timothy Kay found here timkay[dot]com/aws/
To save you the read, it's use is a simple as /usr/bin/s3put bucket/destination/ source/source.gz
My idea for the script is it sends backups (already generated by cpanel) to my S3 bin. Each day it will check with the counter file, how far in the month it is and take the appropriate action.
Since I dont have a test enviroment, only my production server, I was hoping some pro's could look this over and see and obvios blunders on my part. I've tried to comment where nessesary.
Help much appricated.
---------- Post updated 25-04-12 at 01:32 PM ---------- Previous update was 24-04-12 at 11:22 PM ----------
I figured some fualty reasoning on my part, so changed the specs a little.
Instead of weekly and every two weeks, why not just every 10 days; for 3 cycles, thus providing a monthly as well.
is this logic sound then:
Last edited by 3xad3u5; 04-25-2012 at 08:34 AM..
Reason: no code tag
Logic question
If $day is less than 10 - then for 1 - 9 your process will run backup -a, so you get nine backups. Is that what you want?
Programming comment:
There is a really good programming concept, sometimes called "DRY" - Don't Repeat Yourself. This block of code is repeated several times
If you create a shell function you can pass it parameters for the one or two strings that are different each time.
Anyway, this lets you quickly see that one of your calls is interesting: monthly weekly and daily for exactly the same operation. Hmm. This may be correct -- but a priori it looks wrong. This is the real benefit of the whole DRY idea.
Find what you are repeating, then feed it the small changes as parameters.
This User Gave Thanks to jim mcnamara For This Post:
Logic question
If $day is less than 10 - then for 1 - 9 your process will run backup -a, so you get nine backups. Is that what you want?
Oh i get it. I only want it to run once in that 10 day cycle, so at the end on day 30, I have 4 backups, one 30 days old, one 20 days old, one 10 days old and one copied from the latest one (todays backup copied across).
Will hte following function be correct then?
Following your logic, is this a good method DRY?
Totally agree with DRY although its not 'new' to me I see I am doing it... Could I use the function you wrote within my script? Or should it be a new file on its own, that I call within the backup.sh file?
---------- Post updated at 05:07 PM ---------- Previous update was at 02:39 PM ----------
Ok, I've updated my script and have the following:
I get the following error though:
Hello all! I am trying to create a script that will copy files from one location, to another but only folders that are filled with thumbnails to an exact directory replica in the second location. For example:
/images/2012/01/19/Event/Photographer/thumbnails
to
... (4 Replies)
Not sure how I should approach this one.
I have server X and Server Y. X is a collector. All files are seperated by hour. Y is used strictly for analysis. I do not always need all files from X. Sometimes other people use Y for analysis and do not always know how to transfer the files from... (3 Replies)
Tim Bass
11-25-2008 01:02 PM
Just as I was starting to worry that complex event processing community has been captured by RDBMS pirates off the coast of Somalia, I rediscovered a new core blackboard architecture component, Hadoop.
Hadoop is a framework for building applications on large... (0 Replies)
Im trying to transfers a file from one unix server to another , make some changes and then send it back to the original server. All this using modems.
I've been using "cu" and i can "get" the file but i can't "put" it. Besides I need to do this using a shell script. I can write a script to get... (4 Replies)