Skip to content

Instantly share code, notes, and snippets.

@martinvirtel
Last active March 5, 2018 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinvirtel/92a81caa384498db2eb61f9fdba205d8 to your computer and use it in GitHub Desktop.
Save martinvirtel/92a81caa384498db2eb61f9fdba205d8 to your computer and use it in GitHub Desktop.
Backup with S3 and WP All In One Migration Plugini
#!/bin/bash
#
# needs working aws cli
# needs working credentials for wordpress-backup profile to access $BACKUP_DST in ~/.aws/credentials
# needs this plugin: https://wordpress.org/plugins/all-in-one-wp-migration/
export KEEP_FOR_DAYS=+10
export WORDPRESS_NAME="dev.versicherungsmonitor.de"
export BACKUP_DST=s3://bucketname/wordpress_backups/$WORDPRESS_NAME/
export WP_PATH=/var/www/dev.versicherungsmonitor.de/releases/current
export BACKUP_SRC=$WP_PATH/wp-content/ai1wm-backups/
# Clean up older backups
find $BACKUP_SRC -mtime $KEEP_FOR_DAYS -exec rm {} \;
# Backup
wp --path=$WP_PATH ai1wm backup
# Push To Remote
aws --profile=wordpress-backup s3 sync $BACKUP_SRC $BACKUP_DST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment