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

dev-master 2018-01-31 11:11 UTC

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

  1. Create a bucket on aws.
  2. Bucket name: name of the platform
  3. Region: EU (London)
  4. Click on 'Next'
  5. Enable versioning property --> click on versioning --> enable versioning
  6. Click on 'Next'
  7. Click on 'Next'
  8. Click on 'Create bucket'
  9. You have created a bucket, now create a user for this bucket on IAM.
  10. Click on 'add user'
  11. User name: The name of the bucket + -drupal
  12. Enable the checkbox 'Programmatic access'
  13. Click on 'Next: Permissions'
  14. Click on the block 'Attach existing policies directly'
  15. Click on 'Create policy'
  16. You are now createing a policy
  17. Click on 'Choose a service' --> Searh for S3 --> click on S3
  18. Click on 'Select actions' --> enable the checkbox 'All S3 actions'
  19. 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.
  20. You are done with the policy --> Click on 'Review policy'
  21. Name: the name of the bucket, leave description empty
  22. Click on 'Create policy'
  23. You have created a policy, you can close this internet tab.
  24. Click on 'Refresh'
  25. Search for the name of the policy (Bucket name)
  26. Enable the checkbox left of the policy you want to add
  27. Click on 'Next: Review'
  28. Click on 'Create user'
  29. 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 stored
  • env:AWS_ACCESS_KEY_ID - The AWS access key ID to authenticate
  • env:AWS_SECRET_ACCESS_KEY - The AWS secret access key to authenticate
  • env: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>