π§Ύ What It Does
π¦ Exports your MySQL database to a .sql file
π Runs automatically every day
π§Ή Deletes old backups after 7 days (optional)
π Folder Setup
Create this folder on your PC:
D:\datas\Automatic_Backup
π§βπ» Backup Script
Create a file named:
D:\datas\Automatic_Backup\auto_mysql_backup.bat
Paste this:
@echo off set TIMESTAMP=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%_%TIME:~0,2%-%TIME:~3,2% set TIMESTAMP=%TIMESTAMP: =0% set BACKUP_DIR=D:\datas\Automatic_Backup set DB_HOST=82.197.71.175 set DB_USER=ni set DB_PASS=your_password_here set DB_NAME=bdcommerce_37295 mkdir "%BACKUP_DIR%" 2>nul mysqldump -h %DB_HOST% -u %DB_USER% -p%DB_PASS% %DB_NAME% > "%BACKUP_DIR%\%DB_NAME%_%TIMESTAMP%.sql" forfiles /p "%BACKUP_DIR%" /m *.sql /d -7 /c "cmd /c del @path"
β Replace your_password_here with your actual password.
π Automate It
- Open Task Scheduler
- Click Create Basic Task
- Trigger: Daily
- Action: Start a Program β Select your .bat file
- Done π
β
Example Output
bdcommerce_37295_2025-04-21_03-00.sql
Regards,
N I Rimon
Top comments (0)