I am struggling now in order to automatize my tiny backup system. I managed to gather some piece of code but I cannot make it.
SET @sql_text =
CONCAT (
"SELECT * FROM commandes INTO OUTFILE 'Y:/folder/Archives/BDD-commandes-CSV"
, DATE_FORMAT( NOW(), '%Y%m%d')
, "commandes.csv'"
);
PREPARE s1 FROM @sql_text;
CREATE EVENT BackUpCSV
ON SCHEDULE EVERY 1 HOUR
STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY
ENDS CURRENT_TIMESTAMP + INTERVAL 1 YEAR
DO
BEGIN
EXECUTE s1;
END |
DROP PREPARE s1;
Here is what i tried to do. An error is spotted at line 7 where it is actually a blank line (‘#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 7’)
I would be grateful to get this help. thx
There is all about delimiter. Here is the version which is fine to compile:
Also, I recommend to add
drop event if exists BackUpCSV |ps. I’m not sure this script will work