This allows developers to sync WordPress media libraries between machines over Amazon S3.
It can also be used for backing up websites or even moving websites between servers
The setup will ask you to add these constants to your wp-config.php file:
- LOG_FLUME_REGION
- LOG_FLUME_ACCESS_KEY_ID
- LOG_FLUME_SECRET_ACCESS_KEY
You can obtain these details by creating an IAM user. Here is our guide on how to setup an IAM Amazon user and get the access and secret key that you need.
1. Add the Wordpress plugin to your composer file by navigating to your project and running this inside a terminal:
composer require logsmith/log-flume
wp plugin activate log-flume
And these constants to your wp-config file:
define('LOG_FLUME_REGION','eu-west-2'); //London
define('LOG_FLUME_ACCESS_KEY_ID','');
define('LOG_FLUME_SECRET_ACCESS_KEY','');
wp logflume check_credentials
wp logflume create_bucket <bucket_name>
bucket_name
is usually the address of the site you are currently working on ('website.local')
You will also be asked Create bucket? [y/n]
- supply 'y' if this is a fresh setup. Select N to not do that.
wp logflume sync
Bucket name is usually the address of the site you are currently using
Log-flume can be used to backup a live site as well as sync development assets.
Get log-flume running on local version of the site (using the 'Installation' guide above).
SSH into the live environment and navigate to your WordPress installation.
wp logflume check_credentials
Run to find any issues.
It's always good to separate the dev and live environments.
wp logflume create_bucket <bucket_name>
Create a fresh bucket with the live URL as the bucket name. For example:
wp logflume create_bucket atomicsmash.co.uk
Depending on how often you run this command, the SQL files will start to build up quickly. You can setup an S3 folder lifecycle to auto-delete files older than X number of days.
wp logflume autodelete_sql <number_of_days>
We usually usually retain backups for 30 days:
wp logflume autodelete_sql 30
To get the backup command to run on a regular basis, you need to setup a cron job. Use something similar to this:
/usr/local/bin/wp logflume backup_wordpress --path=/path/to/www.website.co.uk/
If you are using composer in your project then your WordPress core files might be inside a subfolder, please modify the path to reflect this. If WordPress lives inside "/wp/" then the cron job would look like this:
/usr/local/bin/wp logflume backup_wordpress --path=/path/to/www.website.co.uk/wp
If you are using forge, then simply add to the server scheduling panel:
logflume sync [--direction=]
This function runs
sync
and a DB backup.
logflume backup_wordpress
This function runs
sync
and a DB backup.
logflume create_bucket <bucket_name>
Created the required bucket and bucket settings for handling media on S3. It's good to use the current hostname.
logflume select_bucket <bucket_name>
Use this to change the bucket that log-flume is currently sync to.
logflume check_credentials
Performs a simple S3 function to make sure it can access the selected bucket
logflume autodelete_sql
Setup a S3 lifecycle to auto-delete from the SQL folder after a number of days.
Are you receiving an error similar to PHP Fatal error: Uncaught Error: Class 'Aws\S3\S3Client' not found in /path/to/file
Make sure you are requiring your autoload.php generated by composer. We usually add this to the top of our wp-config file:
require( dirname( __FILE__ ) . '/vendor/autoload.php' );