Platform.sh: Backup and Forget

Backup and Forget
Crell
Thu, 12/28/2020 – 20:59

Blog

Platform.sh allows users to create a byte-for-byte snapshot of any running environment, production or otherwise, at any time with a single button click or command line directive. That’s great for one off use, like preparing to deploy a new version or run some large batch process, but what about for routine disaster recovery backups? Can we do those?
Believe it or, not, it’s possible to automate yourself! And it’s only a 3 step process.

The basic idea is that the Platform.sh CLI can be triggered from any automation tool you’d like… including cron from within the application container. It just needs an authentication token available in the environment.
Step 1: Get a token
Create an authentication token for your user or a dedicated automation user. That’s easily done through the UI.
Set that token as a variable on your project, like so:
platform project:variable:set env:PLATFORMSH_CLI_TOKEN <value>
Step 2: Install the CLI
The Platform.sh CLI can be installed as part of a build hook within your project. Simply add the following line to your build hook:
curl -sS https://platform.sh/cli/installer | php
Now the CLI will be available in cron hooks, the deploy hook, or when logging in via SSH. It will use the token you provided a moment ago, and will automatically pick up the project and environment name from the existing environment variables.
Step 3: Snapshot on cron
You can now add a new cron entry to your .platform.app.yaml file, like so:
crons:    snapshot:        spec: ‘0 5 * * *’        cmd: |            if [ “$PLATFORM_BRANCH” = master ]; then                platform snapshot:create –yes –no-wait            fi
That will run the cmd once a day at 5 am UTC. (Adjust for whenever low-traffic time is for your site.) Then if and only if it’s running on the master environment (production), the platform snapshot:create command will run and trigger a snapshot, just as if you’d run the command yourself. Poof, done.
Of note, though, are the –yes –no-wait flags. The first skips any user-interaction, since the command is running from cron. The second is extra important, as it tells cron to not block on the snapshot being created. If you forget that, cron will block on the snapshot which means so will any deploy you happen to try and trigger. That can result in extra-long deploys and site downtime. You don’t want that, we don’t want that, so make sure not include –no-wait.
That’s it that’s all, you’re done! Rejoice in daily automated backups of your production environment.

Larry Garfield

3 Jan, 2020


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Platform.sh: Backup and Forget

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.