bash - Postgres backup script on Ubuntu + cron -


i try auto backup script running.

the script works perfectly, if run typing "bash backup.su" terminal. every query , operation have input password (database user), works fine.

but don't use terminal (eg via cron), doesn't. prints out logfile without information.

i think has user rights

terminal output:

making backup directory in /scripts/2013-09-26-daily   performing schema-only backups ------------------------------------------ password user backupuser: <- query getting databases string in name following databases matched schema-only backup:  performing full backups ------------------------------------------ password user backupuser: <- query getting databases plain backup of db1 password: plain backup of db2 password: plain backup of andsoon password: database backups complete! 

cron log:

making backup directory in /scripts/2013-09-26-daily/  performing schema-only backups ------------------------------------------ following databases matched schema-only backup:  performing full backups ------------------------------------------  database backups complete! 

as can see there seems no query executed. right i'm using special backup user, doesn't work postgres. (with postgres user ask password... empty 1 stops script)

does have clue me? said works manually, bot doesn't cron.

greetings

martin

when running interactively have tty, when running cron there no tty attached, i.e. script has no stdin read (that block script while waiting input can never entered anywhere).

you should make script runnable without password, e.g. run under specific user account , configure postgres allow user connect without password (i.e. edit pg_hba.conf).


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -