2017 © Pedro Peláez
 

library platform-backup

image

benjy/platform-backup

  • Saturday, December 30, 2017
  • by benjy
  • Repository
  • 1 Watchers
  • 5 Stars
  • 631 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 33 % Grown

The README.md

Automated backup script that pulls the database, compresses, and syncs to an S3 bucket. Designed for Platform.sh, (*1)

Install

You can either clone this repo and use as its own project or you can require it as a dependency into your existing project., (*2)

composer require benjy/platform-backup, (*3)

Setup

  • composer install
  • Create IAM user with write access to a S3 bucket.
  • Add backups directory to .platform.app.yaml
mounts:
    "/backups": "shared:files/backups"
  • Add environmental variables in Platform.sh. Be sure to add the "env:" prefix., (*4)

    • env:AWS_ACCESS_KEY_ID
    • env:AWS_SECRET_ACCESS_KEY
    • env:S3_BUCKET (The name of the bucket you created)
    • env:LOGGLY_TOKEN (Get from loggly > source setup > tokens)
    • env:AWS_REGION (Optional, defaults to us-east-1)
    • env:PUBLIC_FILES_DIRECTORY (optional: If added use, full path [e.g. /app/app/sites/default/files])
    • env:PRIVATE_FILES_DIRECTORY (optional: If added use, full path [e.g. /app/private])
  • Add composer install to .platform.app.yaml, (*5)

hooks:
    build: |
        composer install --working-dir=./jobs
  • Deploy and test using: php ./jobs/db_backup.php
  • Add cron task to .platform.app.yml
db_backup:
    spec: "0 0 * * *"
    cmd: "php ./jobs/db_backup.php"

Note, you might have to update the cmd to point to a different location depending on how you installed., (*6)

Credits

Adapted from https://bitbucket.org/snippets/kaypro4/gnB4E, (*7)

The Versions