Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2012
    Posts
    30

    Impossible postgresql crontab backup on linux centos

    Hi to All,

    coul Someone resolve this problem?


    1.) If on Linux Centos I execute this file:

    Code:
    # /usr/bin/backup.sh
    wich contains

    Code:
        #!/bin/bash
        export PGPASSWORD=”mia_password_del_db” && pg_dump -h localhost -U user -c  -R -v nome_database -n nome_schema > /percorso/dove/salvare/il/file.sql



    I obtain a perfect backup in file.sql

    2.) But if I put in crontab

    Code:
        * 10 * * * root /usr/bin/backup.sh


    I obtain file.sql empty with zero bytes.

    Tanks in advance.
    Gianni Pinna.
    Last edited by Pat Phelan; 12-28-12 at 17:35. Reason: Replaced manged QUOTE markers with working CODE markers

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    14,947
    1. Is the crontab file owner the same login that you used to launch the backup.sh file from 1) above?
    2. Is the /etc/passwd file set correctly for the owner of the crontab file?
    3. If in doubt, consult CentOS 5.5 - crontab(5)
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,013
    Your crontab entry should not contain the word "root".
    The format is the 5 frequency fields followed by the command, the user/owner field that you have entered is not required.

  4. #4
    Join Date
    Dec 2012
    Posts
    30

    [resolved]

    Hi to All,

    many tanks to -PatP and to Kitaman for the Kind answer.

    THE SOLUTION :It was necessary to type the entire path:

    /opt/PostgreSQL/8.4/bin/pg_dump etc.

    Without it the postgres command was not found.

    Abou, root not required, Kitaman, it is working well, also if I'll try without it.

    Best Rgrds.
    Gianni Pinna.

  5. #5
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,013
    When you are developing a new cron script, it is helpful to add the following line at/near the beginning.
    Code:
    env >/tmp/mycronscript.log
    You can then compare that output with the environment in a terminal session.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •