I am taking backup of my database using mysqldump. But I want to take a backup of my database every one hour. that's why I want to delete my old backups. Only the last 3 backups will be kept in the backup directory. How can I achieve that?
Asked
Active
Viewed 435 times
0
-
Create a shell script to delete files older than x hours. https://stackoverflow.com/questions/249578/how-to-delete-files-older-than-x-hours/249591 Call that script in your backup script/code. – ash__939 Mar 09 '21 at 09:12
-
is there any way to do this without a shell script? – Naowas Morshed Eimon Mar 09 '21 at 09:35
-
Create a scheduled task in Laravel that will execute on an hourly basis. Use filemtime in PHP to get the file modification time. Delete files that are older than X hrs. Use mysqldump to create the backup. You can use exec() to run mysqldump command. – ash__939 Mar 09 '21 at 11:16