Rewriting a bash script in python

Jorgen Grahn grahn+nntp at snipabacken.se
Wed Nov 5 12:23:48 EST 2008


On Tue, 04 Nov 2008 22:11:37 -0500, Chris Jones <cjns1989 at gmail.com> wrote:
> I wrote a trivial backup script that does the following:
>
> If tonight is the first day of the month:
>
>     save last month's archive
>     do a full backup of the system
>
> else:
>
>     save last night's differential backup
>     back up all changes relative to the current month's full backup
>
> endif
>
> I wrote this in bash and although it's worked w/o a glitch for the last
> couple of months .. I'm not comfortable with .. "the look & feel of it".

This sounds like a job for cron(8) -- it's designed for exactly these
things: doing things based on calendar events.  I assume you already
run your backups from cron rather than staying up every night to do
your stuff, so what about changing this in your crontab

   00 1 * * * full_or_incremental_backup

to this?

   00 1 1    * * backup --full
   00 1 2-31 * * backup --incremental

(Or maybe two different scripts suit you better.)

That way you needn't implement your own logic for deciding when to do
a full backup. (You still need a way to find the latest full backup,
though.)

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.se>          R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list