burst / d8_s3_backup
Creates a backup from a Drupal 8 hosted on platform.sh and syncs this to S3.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 13 773
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Language:Shell
This package is not auto-updated.
Last update: 2024-02-18 01:55:24 UTC
README
This repository can be installed into every Drupal 8 project that runs on platform.sh. It automatically backups the filesystem and databases every night and enables you to restore the filesystem or databases with a single command.
Installation
Clone this repository into <project_root>/bin
.
AWS S3
TODO:
- Create user
- Create policy
- Create bucket
- Enable object versioning
- Look up AWS credentials
Setup
- Create a bucket on aws.
- Bucket name: name of the platform
- Region: EU (London)
- Click on 'Next'
- Enable versioning property --> click on versioning --> enable versioning
- Click on 'Next'
- Click on 'Next'
- Click on 'Create bucket'
- You have created a bucket, now create a user for this bucket on IAM.
- Click on 'add user'
- User name: The name of the bucket + -drupal
- Enable the checkbox 'Programmatic access'
- Click on 'Next: Permissions'
- Click on the block 'Attach existing policies directly'
- Click on 'Create policy'
- You are now createing a policy
- Click on 'Choose a service' --> Searh for S3 --> click on S3
- Click on 'Select actions' --> enable the checkbox 'All S3 actions'
- Click on 'Resources' --> Click on 'add ARN' under the bucket tab --> add the name for the bucket in 'Bucket name' --> Click on 'Save changes' --> Enable the checkbox 'Any' under the object tab.
- You are done with the policy --> Click on 'Review policy'
- Name: the name of the bucket, leave description empty
- Click on 'Create policy'
- You have created a policy, you can close this internet tab.
- Click on 'Refresh'
- Search for the name of the policy (Bucket name)
- Enable the checkbox left of the policy you want to add
- Click on 'Next: Review'
- Click on 'Create user'
- Congratulations, you have created a User. Copy the access key and the secret access key, you need these key to set the environment variables.
Platform.app.yaml
You need to add some configuration in <project_root>/platform.app.yml
to install and periodically run the scripts.
Crons
crons:
backup:
spec: '0 4 * * *'
cmd: '/bin/bash -e bin/S3/backup.sh'
Note: You can edit spec
to manage at what time the backups run. The example above runs every night at 04:00.
Hooks
hooks:
build: /bin/bash -e bin/S3/install.sh
ENV vars
The following ENV vars need to be added to platform.sh:
env:WEBROOT
- The webroot where drush commands will be executed (usually/app/web
)env:S3_BUCKET
- The S3 bucket name where backups will be storedenv:AWS_ACCESS_KEY_ID
- The AWS access key ID to authenticateenv:AWS_SECRET_ACCESS_KEY
- The AWS secret access key to authenticateenv:S3_BACKUP_FILESYSTEM_ENABLED
- 1 (on) or 0 (off)env:S3_BACKUP_DATABASE_ENABLED
- 1 (on) or 0 (off)
Usage
Backup
Backups are automatically made every night. Database backups are stored by datetime in the filename. File backups are managed by AWS S3 bucket versioning.
TODO: Manual backup
- Manually backup the filesystem:
command
. - Manually backup all databases:
command
. To backup the database of only one site, add the flag--site=<sitename_here>
TODO: Restore
- Restore filesystem:
command
. - Restore all databases:
command
. To restore the database of only one site, add the flag--site=<sitename_here>