TurnKey Linux Virtual Appliance Library

Permissions issue when making postgres backups in webmin

Maybe somebody here can answer this.

 


I have an ubuntu server running 10.04.1 which I have webmin 1.52 installed. In the Postgres server tab in webmin you can setup and run backups of your databases. When I try to make a backup and choose the option "Create destination directory?" I choose Yes, because I want each backup in its own directory. When I click "backup now" the script fails and says permission denied when trying to write to the directory it just made and I have to log into the server and do a chmod to that directory and then run the backup in webmin again. So my question is why am I getting that permissions error when I try to make a directory in the postgres backup GUI? Shouldn't it make the directory its making automatically writable? or am I missing something? 

Hope I was clear enough, thanks!

Jeremy's picture

So you're not running TKL?

Even if you're not then it should be somewhat similar (TKL v11.x is basd on Ubuntu 10.04).

My first guess is that folder is owned by root, but the backup process is running as a limited user. To troubleshoot this, I'd check who owns the newly created folders, what permissions are set by default. Then change permissions on the folders (to 777) and run your backup. Then check the ownership/permissions of the new files.

Thanks for the response, yes

Thanks for the response, yes the server in this case I created with turnkey. 

 

Anyway I ran another test backup as you suggested and took at look at whole owned the directory that the backup script made, its owned by root. When I chmod the directory its also owned by root.

 

 

 

drwxrwxrwx  2 root root     4096 May  3 17:43 pg20120503
drwxr-xr-x  2 root root        4096 May  4 15:10 pg20120504
 
 
The may 3 is the one I made were I had to go and chmod the directroy that was made and then had to go back into webmin and run the backup script agian.
 
the may 4 one is the one i just made without chmod the directory.
 
here is the error i get in webmin
 
Failed to backup database : pg_dump failed :
	pg_dump: [archiver] could not open output file "/var/backups/pg20120504/nearby.sql": Permission denied

Failed to backup database : pg_dump failed :

	pg_dump: [archiver] could not open output file "/var/backups/pg20120504/nearby_test.sql": Permission denied

Failed to backup database : pg_dump failed :

	pg_dump: [archiver] could not open output file "/var/backups/pg20120504/postgres.sql": Permission denied

Database template0 is not accepting connections.

Failed to backup database : pg_dump failed :

	pg_dump: [archiver] could not open output file "/var/backups/pg20120504/template1.sql": Permission denied

Scheduled backup for database left disabled.

Backup DB fix

You have to chmod 777 and chown root:root your filename-backup.sq file then woola! I'm sure it works.. :)

chmod postgres:postgres -R

chmod postgres:postgres -R /var/your-postgresql-backup-dir/

 

 

ouuupsss ! chown

ouuupsss !

chown postgres:postgres -R /var/your-postgresql-backup-dir/

 

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)