Scheduled Tasks & Retention Automation SOP
This document defines the configuration of automated operational tasks running under Synology DSM Task Scheduler and the retention purge policies that keep backup volumes clean.
1. Task Scheduler Configuration (Synology DSM)
The Cisco SG300 configuration backup runs under the DSM graphical Task Scheduler (synoschedtask), executing with root privileges so it can write directly to the backup shares and bind pseudo-terminals.
Task Specifications
- Task Name:
Backup Cisco Switch Config - User Account:
root - Event / Trigger: Scheduled Daily
- Execution Time:
02:00 AM - Frequency: Every day (
0 2 * * *) - Standard Output Log:
/volume1/Backup/scripts/logs/backup_last_run.log
User-Defined Script Command
Under the Task Settings tab in DSM Task Scheduler, the execution command is configured as:
bash
/usr/bin/python3 /volume1/Backup/scripts/cisco_backup.py >> /volume1/Backup/scripts/logs/backup_last_run.log 2>&12. Directory Structure & Log Management
Execution logs and configuration archives are organized into dedicated subdirectories on /volume1/Backup:
text
/volume1/Backup/
├── scripts/
│ ├── cisco_backup.py # Active Python PTY automation script
│ ├── purge_retention.sh # 30-day retention maintenance script
│ └── logs/
│ ├── backup_last_run.log # Standard output & error stream of last backup
│ └── retention.log # Log of purged stale backups
└── System/
└── CiscoSg300/
├── sg300_20261027_020001.cfg
├── sg300_20261028_020002.cfg
└── sg300_20261029_020001.cfg3. Automated 30-Day Retention & Purge Policy
A maintenance script automatically removes switch backups older than 30 days.
bash
#!/bin/sh
BACKUP_DIR="/volume1/Backup/System/CiscoSg300"
LOG_FILE="/volume1/Backup/scripts/logs/retention.log"
RETENTION_DAYS=30
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting retention cleanup..." >> "$LOG_FILE"
find "$BACKUP_DIR" -type f -name "sg300_*.cfg" -mtime +$RETENTION_DAYS -exec echo "Removing stale backup: {}" >> "$LOG_FILE" \; -exec rm -f {} \;
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Retention cleanup complete." >> "$LOG_FILE"