3.7 KiB
3.7 KiB
Test Scheduled Backup - 1 Minute Setup
Quick Test Setup (1 Minute Interval)
Step 1: Open Task Scheduler
- Press
Win + R - Type
taskschd.msc - Press Enter
Step 2: Create Test Task
- Click "Create Task" (not Basic Task)
- General Tab:
- Name:
Recipe DB Backup TEST - Description:
Test backup every 1 minute - Select "Run whether user is logged on or not"
- Check "Run with highest privileges"
- Name:
Step 3: Set 1-Minute Trigger
- Go to Triggers tab
- Click "New..."
- Configure:
- Begin the task:
On a schedule - Settings:
Daily - Recur every:
1 days - Start: Set to current time (e.g., if it's 3:00 PM, set to 3:00 PM)
- Check "Repeat task every":
1 minute - For a duration of:
1 hour - Check "Enabled"
- Begin the task:
- Click OK
Step 4: Set Action
- Go to Actions tab
- Click "New..."
- Configure:
- Action:
Start a program - Program/script: Browse to
run_backup.bator paste full path:C:\Users\dvirl\OneDrive\Desktop\gitea\my-recipes\backend\run_backup.bat - Start in:
C:\Users\dvirl\OneDrive\Desktop\gitea\my-recipes\backend
- Action:
- Click OK
Step 5: Settings
-
Go to Conditions tab:
- Uncheck "Start the task only if the computer is on AC power"
-
Go to Settings tab:
- Check "Run task as soon as possible after a scheduled start is missed"
- Check "If the task fails, restart every: 1 minutes"
- Attempt to restart up to:
3 times - Check "Stop the task if it runs longer than: 30 minutes"
-
Click OK
-
Enter your Windows password when prompted
Step 6: Monitor Test Results
Check the backup log:
cd C:\Users\dvirl\OneDrive\Desktop\gitea\my-recipes\backend
type backup.log
Or open in Notepad:
- Navigate to
backend\backup.log - Should see new entries every minute
Check R2 bucket:
- Login to Cloudflare Dashboard
- Go to R2 → my-recipes-db-bkp
- Should see new backup files appearing every minute
Expected Log Output
[2025-12-21 15:30:45] Starting backup...
[2025-12-21 15:30:47] Creating database dump...
[2025-12-21 15:30:49] Compressing file...
[2025-12-21 15:30:51] Uploading to R2...
[2025-12-21 15:30:53] Backup completed: recipes_db_20251221_153045.sql.gz
[2025-12-21 15:30:53] Size: 2.5 MB
Verify It's Working
Wait 2-3 minutes and check:
- ✅
backend\backup.loghas multiple entries - ✅ R2 bucket has new backup files
- ✅ Task Scheduler shows "Last Run Result: (0x0)" = Success
If It Works - Convert to Weekly
- Open Task Scheduler
- Find "Recipe DB Backup TEST"
- Right-click → Properties
- Go to Triggers tab
- Edit the trigger:
- Settings: Change to
Weekly - Recur every:
1 weeks - Days: Select
Sunday(or your preferred day) - Time:
02:00:00(2 AM) - Uncheck "Repeat task every"
- Settings: Change to
- Click OK
- Rename task: Right-click → Rename → "Recipe DB Weekly Backup"
Troubleshooting
No backup.log file:
- Task might not be running
- Check Task Scheduler History tab
- Run
run_backup.batmanually first
backup.log shows errors:
- Check if Python is in PATH
- Verify database credentials in
.env - Verify R2 credentials in
.env
Task shows "Could not start":
- Verify the paths are correct
- Make sure you entered Windows password
- Try "Run" button in Task Scheduler manually
Want to stop test:
- Right-click task → Disable
- Or delete the task
Manual Test First
Before setting up Task Scheduler, test manually:
cd C:\Users\dvirl\OneDrive\Desktop\gitea\my-recipes\backend
run_backup.bat
Check if:
- backup.log is created
- Backup appears in R2
- No errors in log
If manual test works, Task Scheduler will work too!