Skip to content

Backup

Backup #1

Workflow file for this run

name: Backup
on:
schedule:
- cron: '0 4 * * 0' # Every Sunday at 4 AM
workflow_dispatch: # Manual trigger
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Create backup
run: |
echo "Creating backup..."
# Create timestamp
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
# Create backup filename
BACKUP_FILE="dm-shorts-blocker-backup-$TIMESTAMP.zip"
# Create backup excluding unnecessary files
zip -r "$BACKUP_FILE" . \
-x "node_modules/*" \
-x ".git/*" \
-x "build/*" \
-x "build-firefox/*" \
-x "*.zip" \
-x ".DS_Store" \
-x "*.log" \
-x "coverage/*" \
-x ".nyc_output/*"
echo "Backup created: $BACKUP_FILE"
echo "backup_file=$BACKUP_FILE" >> $GITHUB_OUTPUT
- name: Upload backup to GitHub
uses: actions/upload-artifact@v4
with:
name: backup-${{ github.run_id }}
path: ${{ steps.backup.outputs.backup_file }}
retention-days: 90
- name: Upload to external storage (if configured)
if: env.BACKUP_WEBHOOK
run: |
echo "Uploading to external storage..."
# Upload to external service (example with curl)
curl -X POST \
-H "Content-Type: application/zip" \
--data-binary "@${{ steps.backup.outputs.backup_file }}" \
"${{ secrets.BACKUP_WEBHOOK }}"
echo "Backup uploaded to external storage"
- name: Cleanup old backups
run: |
echo "Cleaning up old backups..."
# Keep only last 10 backups
# This would be implemented based on your storage solution
echo "Cleanup completed"
- name: Notify backup completion
uses: sarisia/actions-status-discord@v1
if: env.DISCORD_WEBHOOK
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: success
title: "💾 Backup Completed"
description: |
Weekly backup has been completed successfully.
**Backup File:** ${{ steps.backup.outputs.backup_file }}
**Repository:** ${{ github.repository }}
**Branch:** ${{ github.ref }}
Backup will be retained for 90 days.