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.