Actually, that's how i have it setup now--7 different cron jobs for
each day of the week. the only difference between all 7 diff scripts
is the day directory such as "1. Sun" or "2. Mon" etc. I'd like to
make it a little more professional and a lot easier should i want to
backup more stuff (which i do) such as my sites and other parts in my
webhost (my webhost supports multiple websites in one account. ex:
/home/me/domain1.com, /home/me/domain2.com, /home/me/domain3.com,
this way i only need to type in the shell command once, in one file,
and only have to stick a variable which changes the day for me. doing
it 7 different times is too much work when i know there's a way to do
> Would (as a newbie) is not be simpler to setup seven scripts and execute
> them from the crontab file?
> I may be strange, but I like to get a simple solution working first, then
> make it 'better'
> 0 4 * * sun <script for Sunday>
> 0 4 * * mon <script for Monday>
> I'm assuming you want to only keep the last seven days' backups. Otherwise
> you could take to output file and give it a name based on the date. I'm not
> sure of a simple way to do it, but you could tarball it and give the file a
> name from the date.
> > Been trying to figure this out for an hour now. Here's the thing: I'm
> > trying to setup a cron job so that it automatically backsup my sql db
> > everyday of the week sun-sat. the problem is that i cant seem to get
> > the var passed in the path. below is a little bit of the code (my goal
> > here is to get the $day var passed into the path)
> > #!/bin/bash
> > #
> > sun='1. Sun'
> > mon='2. Mon'
> > tues='3. Tues'
> > wed='4. Wed'
> > thurs='5. Thurs'
> > fri='6. Fri'
> > sat='7. Sat'
> > mysqldump -u USERNAME -pPASS --opt MYSQLdB >
> > /home/me/backups/$day/SQLdB.sql
> > <rest of code here to change the $day=$mon etc>
> > whenever this much is executed it gives me
> > backups.cron: /home/me/backups/$day/SQLdb.sql: ambiguous redirect
> > even if i initialize $day as $sun ($day = $sun) or use $sun in the
> > code
> > (mysqldump -u USERNAME -pPASS --opt MYSQLDB >
> > /home/me/backups/$sun/SQLdb.sql)
> > hmm, just realized something. how would i even create a script
> > (ignoring the idea if i hardcoded $sun to the backup path) that can be
> > used to rotate days if it executes, dies, then rerun the next day; it
> > cant change its own code and doesnt say in memory forever.