Skip to main content

How to Set Up Automatic File Backups with EasySend API

March 20, 2026 - EasySend Team

Regular backups protect your data. But backups sitting on the same server as the original data do not protect against hardware failure, ransomware or accidental deletion. Offsite backups fix this. Here is how to set up automatic file backups using the EasySend API.

Bash Script: Daily Database Backup

#!/bin/bash
# backup-share.sh - Daily database backup to EasySend
DATE=$(date +%Y-%m-%d)
BACKUP="/tmp/db-backup-$DATE.sql.gz"

# Create backup
mysqldump --single-transaction mydb | gzip > "$BACKUP"

# Upload to EasySend
RESULT=$(curl -s -F "files[]=@$BACKUP" \
  -F "[email protected]" \
  https://easysend.co/api/v1/upload)

# Extract share link
LINK=$(echo "$RESULT" | grep -o '"share_url":"[^"]*"' | cut -d'"' -f4)
echo "[$DATE] Backup shared: https://easysend.co$LINK" >> /var/log/backups.log

# Clean up local file
rm "$BACKUP"

Set Up as Cron Job

# Run daily at 2 AM
crontab -e
0 2 * * * /opt/scripts/backup-share.sh

Python Script: With Error Handling

import requests
import subprocess
import datetime
import logging

logging.basicConfig(filename='/var/log/backups.log', level=logging.INFO)

def backup_and_share():
    date = datetime.date.today().isoformat()
    backup_path = f"/tmp/backup-{date}.sql.gz"

    # Create backup
    subprocess.run(
        f"mysqldump --single-transaction mydb | gzip > {backup_path}",
        shell=True, check=True
    )

    # Upload
    try:
        r = requests.post(
            "https://easysend.co/api/v1/upload",
            files={"files[]": open(backup_path, "rb")},
            data={"notify_email": "[email protected]"},
            timeout=120
        )
        r.raise_for_status()
        link = r.json().get("share_url", "")
        logging.info(f"Backup {date}: https://easysend.co{link}")
    except Exception as e:
        logging.error(f"Backup {date} failed: {e}")
    finally:
        import os
        os.remove(backup_path)

if __name__ == "__main__":
    backup_and_share()

What Gets Backed Up

This approach works for any file your server generates:

Retention and Security

See the CLI automation guide and cURL guide for more scripting examples.

View API Docs

Get notified about new features and tips

No spam. Unsubscribe anytime.

More from the blog

How to Share Large Files for Free in 2026
Feb 10, 2026
E2E Encrypted File Sharing: Why It Matters
Feb 10, 2026
The Developer's Guide to EasySend API
Feb 11, 2026