mirror of
https://github.com/FoggedLens/deflock.git
synced 2026-02-12 15:02:45 +00:00
Directus Backup Script
This script automates backups for a Directus instance, zipping key directories and uploading the archive to an S3 bucket. It is designed to be run as a cron job for regular, automated backups.
Features
- Zips the
database,extensions, anduploadsdirectories from your Directus instance - Uploads the backup archive to an S3 bucket with a timestamped filename
- Assumes an AWS IAM role for secure S3 access
- Cleans up temporary files after upload
Prerequisites
- Bash shell
ziputility installed- AWS CLI installed and configured
- An IAM user with permission to write to the bucket
Setup
- Clone or copy the script to your server.
- Create a
.envfile in the same directory as the script with the following variables:ROLE_ARN=arn:aws:iam::123456789012:role/directus-backup-writer BUCKET_NAME=your-s3-bucket-name SOURCE_DIR="/path/to/your/directus-instance" - Install dependencies:
- On Ubuntu/Debian:
sudo apt-get install zip awscli jq - On CentOS/RHEL:
sudo yum install zip awscli jq - On Alpine:
sudo apk add zip aws-cli jq
- On Ubuntu/Debian:
- Test the script manually:
./directus-backup.sh - Set up a cron job to run the script automatically. For example, to run every day at 2am:
0 2 * * * /path/to/directus-backup.sh >> /var/log/directus-backup.log 2>&1