Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a shell script to do an incremental backup of MySQL database.
For point in time recovery I'm using the binary logs generated in /var/lib/mysql directory.
For point-in-time recovery, Im creating an sql file using the following statement.

mysqlbinlog --start-datetime="$STARTTIME" --stop-datetime="$ENDTIME" $file > $NOW.test.sql

The incremental backup happens such that the $STARTTIME is going to be the end time of the Fullbackup and $file is the list of log files generated since the fullbackup endtime to the time of start of incremental backup.
My question is how can I create a .sql file in /var/lib/mysql folder and move that file to the destination . When I try the above statement, it says permission denied. How can i achieve this? I know the permissions for the file has to be changed. Is there any alternative for this.

share|improve this question
how you are planing point in time recovery script. I means on what basis you are writing the script to find out last bin log file position and current bin log file,position. – ashuthosh Feb 21 '13 at 5:53
@ashuthosh NEWFULLLOG=ls -d /usr/local/mysql/data/mysql-bin.??????| sed 's/^.*\.//'| sort -g| tail -n 1 – Rudra Feb 21 '13 at 11:10
I changed permissions of that directory is working now – Rudra Feb 25 '13 at 11:53

Your Answer


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

Browse other questions tagged or ask your own question.