Backup & Maintenance
Keep your data safe with automated database backups, rotation policies, and scheduled cron jobs. Also covers Roku channel packaging for distribution.
Figure 1: Backup Flow
Database Backup Script
Create a backup script that dumps the PostgreSQL database, compresses it, and stores it with a timestamp.
#!/bin/bash
# backup_rokuchannel.sh
BACKUP_DIR="$HOME/backups/rokuchannel"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
FILENAME="rokuchannel_${TIMESTAMP}.sql.gz"
mkdir -p "$BACKUP_DIR"
PGPASSWORD="$DB_PASS" pg_dump \
-h localhost -p 9433 \
-U postgres -d rokuchannel \
--schema=roku | gzip > "$BACKUP_DIR/$FILENAME"
Backup Rotation
Add rotation to the backup script to keep only the last 7 days of backups, preventing disk space exhaustion.
# Delete backups older than 7 days
find "$BACKUP_DIR" -name "rokuchannel_*.sql.gz" \
-mtime +7 -delete
# Log the backup
echo "$(date): Backup completed - $FILENAME" \
>> "$BACKUP_DIR/backup.log"
Cron Setup
# Edit crontab
crontab -e
# Add daily backup at 2:00 AM
0 2 * * * /home/user/scripts/backup_rokuchannel.sh
Use crontab -l to list your scheduled jobs. Check /var/log/syslog or journalctl -u cron if backups are not running.
Roku Channel Packaging
To distribute the Roku channel, package the BrightScript source into a signed .pkg file.
-
Zip the roku/ directory
Create a .zip file containing the manifest, source, components, and images directories from C:\PROJECTS\ROKU\roku\.
-
Sideload to Dev Device
Upload the .zip to your Roku device's development web interface at http://<roku-ip>.
-
Package for Distribution
Use the Roku developer portal to generate a signed .pkg file for Channel Store submission or private distribution.