#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13

    Automating Backup


    I am planning to automate the backup procedure at periodic levels using cron. To generate dump files with a distinction each time, how can I append the date ?

    eg.,

    pg_dump hris > hris2808021000.dmp

    where hris2808021000.dmp has 28 aug 02, 10:00.

    Is this possible to auto generate by something like ...

    pg_dump hris > hris%date.dmp

    Awaiting your response.

    Thanks & Regards.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    409
    Rep Power
    13

    Cool


    I just figured this one out today:

    pg_dump hris > hris.`date +%A-%b-%d-%Y`

    Not the same format as yours but it's pretty slick.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seattle
    Posts
    133
    Rep Power
    16
    You could also create a script (shell, Perl, Python) and call that from your cron job. That way, you can do much more in your backup process, things like compress the file, FTP the backup file to another location, send an email to interested parties. You might also want to vacuum the db before or after backup, doing that in one cron call may not be that easy.

    Don
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Chennai, India
    Posts
    69
    Rep Power
    13

    Thanks for the replies !


    Originally posted by Ted Striker

    pg_dump hris > hris.`date +%A-%b-%d-%Y`


    That was pretty smart. Well, as I wanted a half hourly backup, I've configured it as follows...

    1. created a table to store date in format ddmonyyyyhh24mi
    2. update the table before the backup
    3. use a select on the table and append the date to the destination file of pg_dump.

    In practise, this will also result in loss of data for the past half an hour, depending on the time of failure.

IMN logo majestic logo threadwatch logo seochat tools logo