SOLVED - WAS Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-11 Thread Tanstaafl
Just closing out this thread... Thanks to your and Neill and others' help, I've settled on this for my nightly job, that also deletes the oldest hourly's and daily over a certain number to keep: #!/bin/bash BACKUP_DIR=/my/backups/app/sql/nightly BACKUP_DIR_hourly=/my/backups/app/sql/hourly

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-06 Thread Neil Bothwick
On Sun, 05 May 2013 19:21:18 -0400, Tanstaafl wrote: For example, I want to keep 17 hourlies, and 30 nightlies, so I have two cron jobs set up, the hourly, and the nightly. Each backs up to a separate dir. So each time your backup fails, you reduce the number of available backups by one. If

[gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
Ok, another little thing... Is there a simple way to use date/time variables in cronjobs? Or do I need to use a bash script for this? I prefer simple, and just using the variables directly in the cron command would be easier if it works, so figured I'd ask first... I'm trying to schedule a

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Mick
On Sunday 05 May 2013 17:56:33 Tanstaafl wrote: Ok, another little thing... Is there a simple way to use date/time variables in cronjobs? Or do I need to use a bash script for this? I prefer simple, and just using the variables directly in the cron command would be easier if it works, so

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
On 2013-05-05 1:07 PM, Mick michaelkintz...@gmail.com wrote: On Sunday 05 May 2013 17:56:33 Tanstaafl wrote: Ok, another little thing... Is there a simple way to use date/time variables in cronjobs? Or do I need to use a bash script for this? I prefer simple, and just using the variables

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Alan McKinnon
On 05/05/2013 18:56, Tanstaafl wrote: Ok, another little thing... Is there a simple way to use date/time variables in cronjobs? Or do I need to use a bash script for this? I prefer simple, and just using the variables directly in the cron command would be easier if it works, so figured I'd

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
Ok, some of those variables were wrong (copy pasted from my first brain-dead attempt)... I now have a rudimentary bash script with contents: #!/bin/bash BACKUP_DIR=/home/user/mypg_backups PGUSER=superuser PGtt=`date '+%H:%M'` PGhr=`date '+%H'` PGdd=`date '+%a'` PGmm=`date '+%b'` PGyy=`date

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Neil Bothwick
On Sun, 05 May 2013 14:07:50 -0400, Tanstaafl wrote: /home/user/mypg_backups/2013/May/Sun/pg_all-13:54.gz: No such file or directory So, it is expanding the variables properly, but apparently won't automatically create the directories? Is there some kind of flag I can add to the command

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
On 2013-05-05 2:18 PM, Neil Bothwick n...@digimed.co.uk wrote: On Sun, 05 May 2013 14:07:50 -0400, Tanstaafl wrote: /home/user/mypg_backups/2013/May/Sun/pg_all-13:54.gz: No such file or directory So, it is expanding the variables properly, but apparently won't automatically create the

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Todd Goodman
* Tanstaafl tansta...@libertytrek.org [130505 14:32]: On 2013-05-05 2:18 PM, Neil Bothwick n...@digimed.co.uk wrote: On Sun, 05 May 2013 14:07:50 -0400, Tanstaafl wrote: /home/user/mypg_backups/2013/May/Sun/pg_all-13:54.gz: No such file or directory So, it is expanding the variables

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Alan McKinnon
On 05/05/2013 20:31, Tanstaafl wrote: On 2013-05-05 2:18 PM, Neil Bothwick n...@digimed.co.uk wrote: On Sun, 05 May 2013 14:07:50 -0400, Tanstaafl wrote: /home/user/mypg_backups/2013/May/Sun/pg_all-13:54.gz: No such file or directory So, it is expanding the variables properly, but apparently

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Neil Bothwick
On Sun, 5 May 2013 16:06:45 -0400, Todd Goodman wrote: mkdir -p $BACKUP_DIR/$PGyy/$PGmm/$PGdd /usr/bin/pg_dumpall -U $PGUSER -o | \ gzip $BACKUP_DIR/$PGyy/$PGmm/$PGdd/pg_all-$PGtt.gz You could have it check first and only do the mkdir if the directory didn't already exist: [[ -d

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
On 2013-05-05 5:25 PM, Neil Bothwick n...@digimed.co.uk wrote: On Sun, 5 May 2013 16:06:45 -0400, Todd Goodman wrote: mkdir -p $BACKUP_DIR/$PGyy/$PGmm/$PGdd /usr/bin/pg_dumpall -U $PGUSER -o | \ gzip $BACKUP_DIR/$PGyy/$PGmm/$PGdd/pg_all-$PGtt.gz You could have it check first and only

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Tanstaafl
Last question... In order to keep only a certain number of backups, what would be the easiest and SAFEST way to delete the older ones? For example, I want to keep 17 hourlies, and 30 nightlies, so I have two cron jobs set up, the hourly, and the nightly. Each backs up to a separate dir.

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Volker Armin Hemmann
Am 06.05.2013 01:21, schrieb Tanstaafl: Last question... In order to keep only a certain number of backups, what would be the easiest and SAFEST way to delete the older ones? For example, I want to keep 17 hourlies, and 30 nightlies, so I have two cron jobs set up, the hourly, and the

Re: [gentoo-user] Using date/time variables in cronjobs?

2013-05-05 Thread Pandu Poluan
On May 6, 2013 4:57 AM, Tanstaafl tansta...@libertytrek.org wrote: On 2013-05-05 5:25 PM, Neil Bothwick n...@digimed.co.uk wrote: On Sun, 5 May 2013 16:06:45 -0400, Todd Goodman wrote: mkdir -p $BACKUP_DIR/$PGyy/$PGmm/$PGdd /usr/bin/pg_dumpall -U $PGUSER -o | \ gzip