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:
- Database dumps (SQL, MongoDB exports)
- Configuration files and environment snapshots
- Log archives
- Generated reports (PDF, CSV)
- Application build artifacts (ZIP)
Retention and Security
- Free tier - backups available for 3 days (good for daily backups with 3-day rolling window)
- 30-day extension ($0.99) - keep monthly snapshots available longer
- Encryption - add
-F "encrypted=1"to encrypt backups with a password - Notifications -
notify_emailalerts you if the backup is downloaded (or if it is not, which may indicate a problem)
See the CLI automation guide and cURL guide for more scripting examples.
View API Docs