Re: [gentoo-user] Rotating cron files

2005-03-30 Thread Craig Duncan
[EMAIL PROTECTED] wrote:
I connected to my office LAN  a postgresql server  with the latest linux
gentoo. 
By means of "crontab" each working day at 3am the following "crono" script
- backing up my complete DB and the /etc dir to a network share - is executed:

#crono
/usr/bin/vacuumdb
/usr/bin/pg_dump -C -O -Fc -Upostgres --file=/root/pg_dump/curve.tar.gz
curve
tar -cz /etc > /root/pg_dump/etc.tar.gz
Therefore each working day night curve.tar.gz is overwritten as well as
etc.tar.gz.
I would like instead to "enumerate" the two files (starting from monday
= 1, till friday=5)
in order to keep a week backup, such as for instance: curve.1.tar.gz , 
curve.2.tar.gz,
. curve.5. tar.gz  and the same for etc.
How can I obtain this result with crontab?
Ciao
Vittorio

--
gentoo-user@gentoo.org mailing list
 

Try something like this...
dow=`date +%w`
bkfile="rootpg_dumpcurve-$dow.tar.gz"
/usr/bin/pg_dump -C -O -Fc -Upostgres --file=$bkfile
Craig
--
gentoo-user@gentoo.org mailing list


RE: [gentoo-user] Rotating cron files

2005-03-30 Thread Dave Nebinger
> I would like instead to "enumerate" the two files (starting from monday
> = 1, till friday=5)
> in order to keep a week backup, such as for instance: curve.1.tar.gz ,
> curve.2.tar.gz,
> .. curve.5. tar.gz  and the same for etc
> 
> How can I obtain this result with crontab?

Use "date +%u" to get the day of the week, as in the following:

#crono
WEEKDAY=`date +%u`
/usr/bin/vacuumdb
/usr/bin/pg_dump -C -O -Fc -Upostgres
--file=/root/pg_dump/curve.$WEEKDAY.tar.gz curve
tar -cz /etc > /root/pg_dump/etc.$WEEKDAY.tar.gz


--
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Rotating cron files

2005-03-30 Thread Kashani
[EMAIL PROTECTED] wrote:
I connected to my office LAN  a postgresql server  with the latest linux
gentoo. 
By means of "crontab" each working day at 3am the following "crono" script
- backing up my complete DB and the /etc dir to a network share - is executed:

I would like instead to "enumerate" the two files (starting from monday
= 1, till friday=5)
in order to keep a week backup, such as for instance: curve.1.tar.gz , 
curve.2.tar.gz,
.. curve.5. tar.gz  and the same for etc
How can I obtain this result with crontab?
Here is my db backup script. It's for mysql, but the idea is the same.
kashani
#!/bin/bash
set -x
HOST=`hostname --fqdn`
LDIR="/var/sqlbackups"
MLOGIN="user"
MPASS="pass"
RHOST="backupserver.domain.com"
RDIR="/var/sqlbackups/$HOST"
RUSER="root"
RKEY="/root/.ssh/dumps"
DATE=`date +"%Y%m%d"`
OLDDATE=`date --date='6 days ago' +"%Y%m%d"`
DUMP="/usr/bin/mysqldump"
GZIP="/bin/gzip"
SCP="/usr/bin/scp"
SSH="/usr/bin/ssh"
cd $LDIR
$DUMP -u$MLOGIN -p$MPASS --all-databases > $HOST-mysql-fulldump-$DATE
$GZIP -9 $HOST-mysql-fulldump-$DATE
$SCP -q -i $RKEY $HOST-mysql-fulldump-$DATE.gz [EMAIL PROTECTED]:$RDIR
# delete old backups
$SSH -i $RKEY -l $RUSER $RHOST rm $RDIR/$HOST-mysql-fulldump-$OLDDATE.gz
rm -rf $HOST-mysql-fulldump-$OLDDATE.gz
--
gentoo-user@gentoo.org mailing list


Re: [gentoo-user] Rotating cron files

2005-03-30 Thread Etaoin Shrdlu
On Wednesday 30 March 2005 17:39, [EMAIL PROTECTED] wrote:

> #crono
> /usr/bin/vacuumdb
> /usr/bin/pg_dump -C -O -Fc -Upostgres
> --file=/root/pg_dump/curve.tar.gz curve
> tar -cz /etc > /root/pg_dump/etc.tar.gz
>
> Therefore each working day night curve.tar.gz is overwritten as well
> as etc.tar.gz.
>
> I would like instead to "enumerate" the two files (starting from
> monday = 1, till friday=5)
> in order to keep a week backup, such as for instance: curve.1.tar.gz ,
> curve.2.tar.gz, .. curve.5. tar.gz  and the same for etc
>
> How can I obtain this result with crontab?

I think cron alone can't handle this.

Modify your script adding this line at the start:

WEEKDAY=`date +%u`

and then give the files names like curve.${WEEKDAY}.tar.gz and 
etc.${WEEKDAY}.tar.gz

-- 
Double your drive space - delete Windows!
--
gentoo-user@gentoo.org mailing list