2

I'm using automysqlbackup, here is the default cron entry created

#!/bin/sh
test -x /usr/sbin/automysqlbackup && /usr/sbin/automysqlbackup

My files are stored here

/var/cache/automysqlbackup

I need to read them with my user but all the dumps are owned by root:root and 600

-rw------- 1 root root 945671 mars  12 06:49 my_2013-03-12.sql.gz
-rw------- 1 root root 951541 mars  13 06:32 my_2013-03-13.sql.gz
-rw------- 1 root root 956770 mars  14 06:31 my_2013-03-14.sql.gz
-rw------- 1 root root 961125 mars  15 06:53 my_2013-03-15.sql.gz
-rw------- 1 root root 969009 mars  17 06:38 my_2013-03-17.sql.gz
-rw------- 1 root root 969139 mars  18 06:38 my_2013-03-18.sql.gz

How can I configure automysqlbackup to use different owner and permissions ?

Pierre de LESPINAY
  • 370
  • 2
  • 6
  • 18

3 Answers3

5

Alternatively, last time I checked automysqlbackup was plain bash so one could easily make a modified local copy....

On Ubuntu, default install for automysqlbackup

$ sudo nano /usr/sbin/automysqlbackup

Search for chmod (only one occurrence) and replace 600 by 640 for example

Pierre de LESPINAY
  • 370
  • 2
  • 6
  • 18
rackandboneman
  • 2,577
  • 11
  • 8
  • 1
    Apparently it's still the case. I found a `chmod 600 $2`, I'm going to try to change it. Maybe I could set it as an option. I'll tell you – Pierre de LESPINAY Mar 18 '13 at 14:11
  • 1
    I would advise you dpkg-divert, or do not modify /usr/sbin/automysqlbackup itself but a copy instead which you wire up into cron instead of the distribution binary. Otherwise, a package update will wreck your changes since /usr/sbin/automysqlbackup is not marked as a conffile. – rackandboneman Mar 19 '13 at 09:19
0

automysqlbackup certainly doesn't inherit permissions from parent directory. I don't know why an option for setting permissions has never been added because it's a nobrainer.

For Debian I did the following:

In /etc/default/automysqlbackup added:

FILEPERM=644

Then I copied the script to the user home who runs the cronjob (so it doesn't get overwritten by system upgrade) and changed line 426:

From

# Database dump function
dbdump () {
        touch $2
        chmod 600 $2

To

# Database dump function
dbdump () {
    touch $2
    chmod ${FILEPERM} $2

Now all permissions are set to what's given in the configuration file. Of course I have to update the cronjob to /home/user/automysqlbackup

user6329530
  • 237
  • 2
  • 13
0

automysqlbackup not have option(how i know), but you can set permission of parent directory:

sudo mkdir /var/cache/automysqlbackup
sudo chgrp YourUserGroup /var/cache/automysqlbackup
sudo chmod 770 /var/cache/automysqlbackup

And files should be inherit group permission of parent directory when make backup. more info at https://dylansserver.com/note/automysqlbackup

update: other variant

mkdir test
chgrp guest test
chmod -R gu+s test
setfacl -d -m u::rw,g::rw,o::- test
cd test && touch file2 && ls -la file2
-rw-rw----   1 root guest    0 march 18 16:33 file2
Rainbow-
  • 81
  • 7