Rsnapshot: folder ownership permissions to 'backups' group instead of root
3
votes
1
answer
1137
views
I am using rsnapshot to make daily backups of a MYSQL database on a server. Everything works perfectly except the ownership of the directory is
root:root
. I would like it to be root:backups
to enable me to easily download these backups to a local computer over an ssh connection. (My ssh user has sudo permissions but I don't want to have to type in the password every time I make a local copy of the backups. This user is part of the *backups* group.)
In /etc/rsnapshot.conf
I have this line:
backup_script /usr/local/bin/backup_mysql.sh mysql/
And in the file /usr/local/bin/backup_mysql.sh
I have:
umask 0077
# backup the database
date=date +"%y%m%d-%h%m%s"
destination=$date'-data.sql.gz'
/usr/bin/mysqldump --defaults-extra-file=/root/.my.cnf --single-transaction --quick --lock-tables=false --routines data | gzip -c > $destination
/bin/chmod 660 $destination
/bin/chown root:backups $destination
The file structure that results is:
/backups/
├── [drwxrwx---] daily.0
│ └── [drwxrwx---] mysql [error opening dir]
├── [drwxrwx---] daily.1
│ └── [drwxrwx---] mysql [error opening dir]
The ownership of the backup data file itself is correct, as root:backups
, but I cannot access that file because the folder it is in, mysql
, belongs to root:root
.
Asked by Kit Johnson
(161 rep)
May 8, 2020, 07:17 AM
Last activity: May 22, 2020, 08:11 AM
Last activity: May 22, 2020, 08:11 AM