Automated daily backup script for databases and sites to S3.
- Dumps all MySQL databases (excluding system databases) and uploads them gzipped to S3 (if MySQL is installed)
- Dumps all PostgreSQL databases (excluding
postgres) and uploads them gzipped to S3 (if PostgreSQL is installed) - Archives site files (
/var/www/*/) including.env,certs,conf, andpersistentdirectories and uploads them gzipped to S3 - Backups rotate on a 31-day cycle based on day of month
- Uploads are rate-limited to 1 MB/s via
pv
s3://rocketeers/backups/{server}/{name}/databases/{day}.sql.gz
s3://rocketeers/backups/{server}/{name}/files/{day}.tar.gz
mysql/mysqldump(optional)psql/pg_dump(optional)s3cmd(at/usr/local/bin/s3cmd)pvgzip
The following placeholders in backup.sh must be replaced before deployment:
| Placeholder | Description |
|---|---|
%MYSQL_USER% |
MySQL username |
%MYSQL_PASSWORD% |
MySQL password |
%SERVER% |
Server identifier for S3 |
%POSTGRES_USER% |
PostgreSQL username |
# typically run via cron, e.g. daily at 3:00 AM
0 3 * * * /path/to/backup.sh >> /var/log/backup.log 2>&1- Discord notifications on success/failure
- Slack notifications on success/failure
- Telegram notifications on success/failure