Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to configure an automatic MySQL backup solution under an Ubuntu server.

I have chosen automysqlbackup and rsync for this purpose (does it seem to be a good choice ?)

rsync will be used in the automysqlbackup #POSTBACKUP callback to send the backup to a remote server after each backup.

I found that automysqlbackup uses root as default user to make his operations.

How can I make automysqlbackup use a dedicated linux user so I'd be able to easily manage ssh keys and things like that ?

Update:

The script attached to #POSTBACKUP would resemble:

#!/bin/bash
rsync -ar /var/lib/automysqlbackup/ \
  backup@my_remote_backup_server:~/remote_backup/$HOSTNAME
share|improve this question
add comment

1 Answer 1

You can switch to another user before running rsync, something like this:

su - mysql -s /bin/bash -c 'rsync -ar ...'

Other some solutions that you might interested in:

share|improve this answer
    
What does your postbackup script look like? –  quanta Mar 11 '13 at 9:36
    
See my updated. –  quanta Mar 11 '13 at 11:14
    
Run it as mysql user instead of root. Make sure that mysql user has write permission to /var/lib/automysqlbackup/. –  quanta Mar 11 '13 at 13:20
    
automysqlbackup runs automatically through cron and following directives from a config file. So I don't know where I should change this user. This config file does not specify the user. –  Pierre de LESPINAY Mar 11 '13 at 13:39
1  
Run it as a cron job of mysql instead of root. –  quanta Mar 11 '13 at 14:30
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.