We're Hiring!

Permissions error with cron pg_dump

Having a problem deploying OMERO? Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

The OMERO.server installation documentation begins here and you can find OMERO.web deployment documentation here.

Permissions error with cron pg_dump

Postby brossetti » Fri Sep 26, 2014 8:10 pm

Hello!

I'm putting the finishing touches on my omero installation and ran into a problem setting up my cron jobs. I followed the suggestions for setting up daily postgres backups with the example script:

Code: Select all
#!/bin/bash

DATE=`date '+%Y-%m-%d_%H:%M:%S-%Z'`
OUTPUT_DIRECTORY=/OMERO/backup/database
DATABASE="omero_database"
DATABASE_ADMIN="postgres"

mkdir -p $OUTPUT_DIRECTORY
chown -R $DATABASE_ADMIN $OUTPUT_DIRECTORY
su $DATABASE_ADMIN -c "pg_dump -Fc -f $OUTPUT_DIRECTORY/$DATABASE.$DATE.pg_dump $DATABASE"


I've set crontab to run this script (located in /home/omero/cron.omero/) as root, but I get the following error when it runs:

Code: Select all
could not change directory to "/root": Permission denied


I've looked around, but I'm not sure where this error is arising. The permissions of the directory with the script are "drwxr-xr-x omero omero" and the output directory permissions are "drwxrwxr-x postgres omero"

Thanks in advance for any suggestions!
Blair
brossetti
 
Posts: 32
Joined: Wed Feb 12, 2014 8:57 pm

Re: Permissions error with cron pg_dump

Postby bpindelski » Mon Sep 29, 2014 8:19 am

Hi Blair,

The error you are reporting is most probably related to using su. By default, this command tries to bring up an interactive shell in the name of the root user. I'm quite sure that the home directory for root doesn't exits, and that's why you get this error. What is surprising is that this still happens even when $DATABASE_ADMIN is provided as an argument.

I usually use sudo for executing any PostgreSQL CLI command on Unix-like operating systems.
I recommend you give this a try.

With kind regards,
Blazej
bpindelski
 

Re: Permissions error with cron pg_dump

Postby brossetti » Wed Oct 01, 2014 4:22 pm

Hi Blazej,

Thank you very much for your insight. In the end, I decided to incorporate this script into my rsnapshot backup routine. In the process, the pgdump.sh script was moved to a different directory and is called using backup_script from rsnapshot. Apparently some magic happened during all of that and now I don't get the error message. This could mean that everything is working nicely or that rsnapshot is suppressing the error message. My guess is that I might have had a bug in my shell script somewhere that I unknowingly sorted out.

Thanks,
Blair
brossetti
 
Posts: 32
Joined: Wed Feb 12, 2014 8:57 pm


Return to Installation and Deployment

Who is online

Users browsing this forum: No registered users and 1 guest