Coder Social home page Coder Social logo

wpsnapshots's Introduction

(DEPRECATED) WP Snapshots

THIS PROJECT IS DEPREACTED IN FAVOR OF THE NEW SNAPSHOTS BUILT AS A WP CLI COMMAND.

A project sharing tool for WordPress.

Support Level Release Version MIT License

Table of Contents

Overview

WP Snapshots is a project sharing tool for WordPress. Operated via the command line, this tool empowers developers to easily push snapshots of projects into the cloud for sharing with team members. Team members can pull snapshots, either creating new WordPress development environments or into existing installs such that everything "just works". No more downloading files, matching WordPress versions, SQL dumps, fixing table prefixes, running search/replace commands, etc. WP Snapshots even works with multisite.

WP Snapshots stores snapshots in a centralized repository (AWS). Users setup up WP Snapshots with their team's AWS credentials. Users can then push, pull, and search for snapshots. When a user pushes a snapshot, an instance of their current environment (wp-content/, database, etc.) is pushed to Amazon and associated with a particular project slug. When a snapshot is pulled, files are pulled from the cloud either by creating a new WordPress install with the pulled database or by replacing wp-content/ and intelligently merging the database. WP Snapshots will ensure your local version of WordPress matches the snapshot..

A snapshot can contain files, the database, or both. Snapshot files (wp-content/) and WordPress database tables are stored in Amazon S3. General snapshot meta data is stored in Amazon DynamoDB.

Upgrade

WP Snapshots 2.0+ allows users to store database and files independently. As such, some snapshots may only have files or vice-versa. Therefore, WP Snapshots pre 2.0 will break when attempting to pull a 2.0+ snapshot that contains only files or database. WP Snapshots 2.0 works perfectly with older snapshots. If you are running an older version of WP Snapshots, you should upgrade immediately.

Install

WP Snapshots is easiest to use as a global Composer package. It's highly recommended you run WP Snapshots from WITHIN your dev environment (inside VM or container). Assuming you have Composer/MySQL installed and SSH keys setup within GitHub/10up organiziation, do the following:

Install WP Snapshots as a global Composer package via Packagist:

composer global require 10up/wpsnapshots

If global Composer scripts are not in your path, add them:

export PATH=~/.composer/vendor/bin:$PATH

If you are using VVV, add global Composer scripts to your path with this command:

export PATH=~/.config/composer/vendor/bin:$PATH

Configure

WP Snapshots currently relies on AWS to store files and data. As such, you need to connect to a "repository" hosted on AWS. We have compiled instructions on how to setup a repository on AWS.

  • wpsnapshots configure <repository> [--region] [--aws_key] [--aws_secret] [--user_name] [--user_email]

    This command sets up WP Snapshots with AWS info and user info. If the optional arguments are not passed to the command, the user will be promted to enter them, with the exception of region which will default to us-west-1.

    Example Usage With Prompts :

    wpsnapshots configure 10up
    

    Example Usage Without Prompts (No Interaction) :

    wpsnapshots configure yourcompany --aws_key=AAABBBCCC --aws_secret=AAA111BBB222 --user_name="Jane Smith" --user_email="[email protected]"
    

If WP Snapshots has not been setup for your team/company, you'll need to create the WP Snapshots repository:

wpsnapshots create-repository <repository>

If a repository has already been created, this command will do nothing.

Usage

WP Snapshots revolves around pushing, pulling, and searching for snapshots. WP Snapshots can push any setup WordPress install. WP Snapshots can pull any snapshot regardless of whether WordPress is setup or not. If WordPress is not setup during a pull, WP Snapshots will guide you through setting it up.

Documentation for each operation is as follows:

  • wpsnapshots push [<snapshot-id>] [--exclude_uploads] [--exclude] [--scrub] [--path] [--db_host] [--db_name] [--db_user] [--db_password] [--verbose] [--small] [--slug] [--description] [--include_files] [--include_db]

    This command pushes a snapshot of a WordPress install to the repository. The command will return a snapshot ID once it's finished that you could pass to a team member. When pushing a snapshot, you can include files and/or the database.

    WP Snapshots scrubs all user information by default including names, emails, and passwords.

    Pushing a snapshot will not replace older snapshots with the same name. There's been discussion on this. It seems easier and safer not to delete old snapshots (otherwise we have to deal with permissions).

    --small will take 250 posts from each post type along with the associated terms and post meta and delete the rest of the data. This will modify your local database so be careful.

  • wpsnapshots pull <snapshot-id> [--path] [--db_host] [--db_name] [--db_user] [--db_password] [--verbose] [--include_files] [--include_db] [--overwrite_local_copy]

    This command pulls an existing snapshot from the repository into your current WordPress install replacing your database and/or wp-content directory entirely. If a WordPress install does not exist, it will prompt you to create it. The command will interactively prompt you to map URLs to be search and replaced. If the snapshot is a multisite, you will have to map URLs interactively for each blog in the network. This command will also (optionally) match your current version of WordPress with the snapshots.

    After pulling, you can login as admin with the user wpsnapshots, password password.

  • wpsnapshots search <search-text>... [--format]

    This command searches the repository for snapshots. <search-text> will be compared against project names and authors. Multiple queries can be used to search snapshots in different projects. Searching for "*" will return all snapshots.

    --format will render output using selected format. Supported formats are table and json. Default value is table.

  • wpsnapshots delete <snapshot-id> [--verbose]

    This command deletes a snapshot from the repository.

Identity Access Management and Security

Snapshots is intended to store development environments. It was not meant to be a secure solution to store sensitive production data in the cloud.

Snapshots relies on AWS for access management. Each snapshot is associated with a project slug. Using AWS IAM, specific users can be restricted to specific projects. It is your responsibility to ensure your AWS cloud environment is properly secured.

PII

Snapshots automatically scrubs user information when creating a snapshot. Scrubbed data only includes standard WordPress data e.g. user name, passwords, some user meta, etc. Certain plugins or custom code my store PII elsewhere. It is strongly recommended you review your project for PII (personal identifable information) before pushing snapshots to AWS.

Troubleshooting

  • WP Snapshots can't establish a connection to the database

    This can happen if you are calling WP Snapshots outside of your dev environment running in a VM or container. WP Snapshots reads database credentials from wp-config.php. In order to connect to your database from your host machine, the database host address will need to be different. For VVV it's 192.168.50.4, for WP Local Docker, it's 127.0.0.1. You can pass a host override via the command line using the --db_host option. For VVV, you also might need to pass in a special database user and password like so --db_user=external --db_password=external. We recommend running WP Snapshots from inside your development environment.

  • I received the error: env: mysqldump: No such file or directory

    You don't have mysqldump installed. This is most likely because you are running WP Snapshots from outside your container or VM. Either install mysqldump or run WP Snapshots inside your container or VM.

  • During a pull, MySQL is timing or erroring out while replacing the database.

    If you are pulling a massive database, there are all sorts of memory and MySQL optimization issues you can encounter. Try running WP Snapshots as root (--db_user=root) so it can attempt to tweak settings for the large import.

  • wpsnapshots search displays signature expired error.

    This happens when your local system clock is skewed. To fix:

    • If you're using VVV, try vagrant reload
    • If you're using Docker, try docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org'
  • wpsnapshots push or pull is crashing.

    A fatal error is most likely occuring when bootstrapping WordPress. Look at your error log to see what's happening. Often this happens because of a missing PHP class (Memcached) which is a result of not running WP Snapshots inside your environment (container or VM).

Windows

WP Snapshots has been used successfully inside Windows Subsystem for Linux.

Support Level

Active: 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.

Like what you see?

Work with us at 10up

wpsnapshots's People

Contributors

christianc1 avatar cmmarslender avatar dinhtungdu avatar dustinrue avatar eugene-manuilov avatar felipeelia avatar jeffpaul avatar lukaspawlik avatar nbejansen avatar nprasath002 avatar paulschreiber avatar psorensen avatar qriouslad avatar tlovett1 avatar tylercherpak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wpsnapshots's Issues

Error when scrubbing user information because of lack of escaping

Describe the bug
I came across this error when I tried to create a new snapshot:

WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Ath' WHERE meta_key='last_name' AND user_id='xxxx'' at line 1 for query UPDATE wp_usermeta_temp SET meta_value='De'Ath' WHERE meta_key='last_name' AND user_id='xxxx' made by require_once('/home/wpsnapshots/.composer/vendor/10up/wpsnapshots/src/bootstrap.php'), Symfony\Component\Console\Application->run, Symfony\Component\Console\Application->doRun, Symfony\Component\Console\Application->doRunCommand, Symfony\Component\Console\Command\Command->run, WPSnapshots\Command\Create->execute, WPSnapshots\Snapshot::create

The error is caused by these lines:

$wpdb->query( "UPDATE {$wpdb->usermeta}_temp SET meta_value='{$dummy_user['first_name']}' WHERE meta_key='first_name' AND user_id='{$user_id}'" );
$wpdb->query( "UPDATE {$wpdb->usermeta}_temp SET meta_value='{$dummy_user['last_name']}' WHERE meta_key='last_name' AND user_id='{$user_id}'" );
$wpdb->query( "UPDATE {$wpdb->usermeta}_temp SET meta_value='{$dummy_user['first_name']}' WHERE meta_key='nickname' AND user_id='{$user_id}'" );

The problem is it uses a single quote, which conflicts with the apostrophe in the user's name:

meta_value='{$dummy_user['first_name']}'

Steps to Reproduce

  1. Make sure you have a user with an apostrophe in their name like Danny De'Ath
  2. Create a snapshot
  3. Choose to save the database
  4. See error

Environment information

  • Device: Macbook Pro
  • OS: MacOS 10.15.6

Additional context
I'm using WP Snapshots with WP Local Docker and the latest WP Snapshots 2.0: 10updocker wpsnapshots create

readme updates

It's not obvious the level of support provided for this repo, so let's add some clarification.

  • add support level section and badge
  • add release version badge
  • add license badge

Consider supporting a .wpsnapshots-ignore file

In the same vein as #6, it might be useful to list out ignored files/paths in a gitignore style, but specific to wpsnapshots.

The wp-cli dist-archive command does something like this with a .distignore file.

This way, we could list common paths to exclude, but also allow this to evolve with the project, allow for exceptions, etc.

WP-CLI subcommand

Do you plan to make this tool a WP-CLI subcommand?
It would be very witty idea.

Generate snapshot local without push to S3

Allow to generate snapshot and stored locally without push to S3.
probably the command something like this:
wpsnapshot push --output=~/backup/

and when doing pull, allow to pull from local
wpsnapshot pull --from=~/backup/project/snaphsot-id

Failed to open data.sql

When running a pull request, an error can come up right after the database update comment (when running verbose):

ERROR at line 1: Failed to open file '/{pathtofiles}/.wpsnapshots/data.sql', error: 2

The issue seems to be that the download is data.sql.gz. Unzipping the archive and putting it into the hidden folder generated seems to fix the issue.

Exclude build files

node_modules, bower_components, and vendor are currently being included in snapshots. These files really slow things down.

Release version 2.2.1

This issue is for tracking changes for the 2.2.1 release. Target release date: TBD.

Pre-release steps

  • Complete review of PR #86, resolve issues/merge

Release steps

  • Branch: Starting from develop, cut a release branch named release/2.2.1 for your changes.
  • Version bump: Bump the version number in src/bootstrap.php if it does not already reflect the version being released.
  • Changelog: Add/update the changelog in CHANGELOG.md.
  • Props: Update CREDITS.md file with any new contributors, confirm maintainers are accurate
  • Readme updates: Make any other readme changes as necessary in README.md.
  • Merge: Make a non-fast-forward merge from your release branch to develop (or merge the pull request), then do the same for develop into master (git checkout master && git merge --no-ff develop). master contains the stable development version.
  • Push: Push your master branch to GitHub (e.g. git push origin master).
  • Release: Create a new release, naming the tag and the release as 2.2.1, and targeting the master branch. Paste the changelog from CHANGELOG.md into the body of the release and include a link to the closed issues on the milestone. The release should now appear under releases.
  • Wait for build: Head to the Actions tab in the repo and wait for it to finish if it hasn't already. If it doesn't succeed, figure out why and start over. The new images should now appear under tags as 2, 2.2.1, and latest.
  • Close milestone: Edit the milestone with release date (in the Due date (optional) field) and link to GitHub release (in the Description field), then close the milestone.
  • Punt incomplete items: If any open issues or PRs which were milestoned for 2.2.1 do not make it into the release, update their milestone to 2.3.0 or Future Release.

Post-release steps

Comments Email Data Scrubs

Is your enhancement related to a problem? Please describe.
WP Snapshots scrubs all user email/data, but not comments name/emails.

Describe the solution you'd like
Comment author is not (always) user. But we need to also remeve this details/replace it with dummy data,

Designs

Describe alternatives you've considered

Additional context

Add option to snapshot entire installation

Some of repositories contain entire WordPress installation instead of only wp-content. Good example are sites on WPEngine using Git Push deployment feature. These sites have to have entire WordPress in repository as they're pushed this way to servers.

Having an option to export full WordPress installation (also .git directory is located in the root of WordPress directory instead of inside wp-content/ or it children) would allow that kind of projects to easily ramp up new engineers as they would have all git remotes set out of the box.

Files archive path is relative to WP_CONTENT_DIR

The files.tar.gz is written to ../.wpsnapshots/files.tar.gz, relative the value of WP_CONTENT_DIR. This is an issue when the wp-content directory isn't in ABSPATH common in "Composer Style" installations of Wordpress where the file structure resembles:

|- wp/
|-- wp-admin/
|-- wp-includes/
|- wp-content/
|-- themes/
|-- plugins/
|-composer.json

The files archive should be written to the same directory the database dump is located, which is aware --path option of the push command.

Document scrubbing features of WP Snapshots

Is your enhancement related to a problem? Please describe.

The readme says this about wpsnapshots push:

WP Snapshots scrubs all user information by default including names, emails, and passwords.

It would be nice to have any public-facing documentation of:

  1. What gets scrubbed
  2. What doesn't get scrubbed
  3. Ways to extend the scrubber to make sure that PII in nonstandard places can be scrubbed and replaced

Designs

n/a

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Tasks

No tasks being tracked yet.

Add a constant when bootstrapping wp snapshot

If you have a wp_redirect on the init hook, it will kill the bootstrapping process and silently fail when running wpsnapshot push.

Perhaps a constant when running snapshot push to handle instances like this would allow us to handle issues like this?

Create Repo failing

AWS client and access are working with the right perms.

WP Snapshots configuration verified and saved.
octagon@hax ~/c/w/updato-test> 10updocker wpsnapshots create-repository dood
Ensuring global network exists

  • Network exists
    Ensuring global cache volume exists
  • Creating Volume
    Ensuring global services are running
    global_mailcatcher_1 is up-to-date
    global_dns_1 is up-to-date
    global_mysql_1 is up-to-date
    global_gateway_1 is up-to-date
    global_phpmyadmin_1 is up-to-date
    Waiting for mysql...

Checking USER ID
Host user is 0:0

The "--db_user" option does not exist.

create-repository

octagon@hax ~/c/w/updato-test>

wpsnapshots push -n results in error, related to #55

Describe the bug
If you issue wpsnapshosts push -n you will get an error because the project slug value isn't present.

When you issue wpsnapshots create -n and then wpsnapshots push <id> the operation does issue the error but it also fails to actually push the snapshot up.

Steps to Reproduce

  1. Create an awesome new project
  2. Attempt to create a snapshot and because you don't want to answer all those pesky questions you pass -n
  3. Become sad because the snapshot fails with
Fatal error: Uncaught Error: Call to undefined method UnexpectedValueException::getAwsErrorCode() in ...vendor/10up/wpsnapshots/src/classes/DB.php on line 167

Expected behavior
As mentioned in #55, adding a --project option would allow someone to create a snapshot without interaction. This is crucial when trying to automate the process as well.

Additional context
One of my goals is to allow wpsnapshots to be scripted/automated. By providing a few more options I believe I can achieve that.

Provide subdomain for multisite pull

When pulling a multisite installation, the system provides path information but not subdomain information. For example:

Multisite installation (subdomain based install) detected.
Replacing URLs for blog 1. Path for blog is /.
Domain (localhost.dev for example):
[snip]
Replacing URLs for blog 3. Path for blog is /.
Domain (localhost.dev for example):

I would propose the system also reads the domain column of wp_blogs to provide output similar to the following (bold added for emphasis):

Multisite installation (subdomain based install) detected.
Replacing URLs for blog 1. Path for blog is /, domain is sub1.localhost.dev.
Domain (localhost.dev for example):

Release version 2.1.0

This issue is for tracking changes for the 2.1.0 release. Target release date: TBD.

Pre-release steps

  • Complete review of PR #41, resolve issues/merge ...or... punt to next release
  • Complete review of PR #57, resolve issues/merge ...or... punt to next release
  • Complete review of PR #78, resolve issues/merge ...or... punt to next release

Release steps

  • Branch: Starting from develop, cut a release branch named release/2.1.0 for your changes.
  • Version bump: Bump the version number in src/bootstrap.php if it does not already reflect the version being released.
  • Changelog: Add/update the changelog in CHANGELOG.md.
  • Props: Update CREDITS.md file with any new contributors, confirm maintainers are accurate
  • Readme updates: Make any other readme changes as necessary in README.md.
  • Merge: Make a non-fast-forward merge from your release branch to develop (or merge the pull request), then do the same for develop into master (git checkout master && git merge --no-ff develop). master contains the stable development version.
  • Push: Push your trunk branch to GitHub (e.g. git push origin master).
  • Wait for build: Head to the Actions tab in the repo and wait for it to finish if it hasn't already. If it doesn't succeed, figure out why and start over.
  • Check the build: Check out the master branch and test for functionality locally.
  • Release: Create a new release, naming the tag and the release with the new version number, and targeting the master branch. Paste the changelog from CHANGELOG.md into the body of the release and include a link to the closed issues on the milestone. The release should now appear under releases.
  • Close milestone: Edit the milestone with release date (in the Due date (optional) field) and link to GitHub release (in the Description field), then close the milestone.
  • Punt incomplete items: If any open issues or PRs which were milestoned for 2.1.0 do not make it into the release, update their milestone to 2.2.0 or Future Release.

Feature Request: Download options and progress

Ideas for some additional options/flags:

  • Set a save location for the download, if you want it elsewhere than the cache for extracting assets manually (--directory)
  • Only download files or database. (--only-files, --only-db)

Additionally, a progress bar should be added so you know how far along your download is. Especially since some of these snapshots can be many gigabytes in size, it can be beneficial for the user to see how far along the download is.

Permissions issue

Permissions on the files seems to be getting changed at some point in the process.
old mode 100644
new mode 100755

This might have something to do with the way the files are returned from s3.

Is anyone else experiencing this or is it an issue with the specific repo?

Install issues: symfony/console package version

I just tried to install WP Snapshots.

I ran:

composer global config repositories.wpsnapshots vcs https://github.com/10up/wpsnapshots

and then:

composer global require 10up/wpsnapshots:dev-master -n

Which gave me an error: Your requirements could not be resolved to an installable set of packages.

I'm attaching full screenshot of output.

Does this mean I have to downgrade my symfony/console package? I run composer show global and see: symfony/console v4.1.3 Symfony Console Component

screenshot 2018-08-02 11 24 52

Create Environment command

create-environment <instance-id> [--environment] (suggestion)

This command should let a user start from scratch.

  1. Install dev environment of users choosing
  2. Pull instance

Add PHPCS

We should add PHPCS. However, normal WP standards don't really make sense as this isn't a WP plugin/theme.

Invalid signature when using PHP 7.4

When using PHP 7.4.16 with Ubuntu running in WSL/2 I get this error running wpsnapshots pull or wpsnaphsots search. Switching to PHP 7.3.27 resolved my issue.

Error executing "Scan" on "https://dynamodb.us-west-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://d
  ynamodb.us-west-1.amazonaws.com` resulted in a `400 Bad Request` response:
  {"__type":"com.amazon.coral.service#InvalidSignatureException","message":"The request signature we calculated does
  not m (truncated...)
   InvalidSignatureException (client): The request signature we calculated does not match the signature you provided.
   Check your AWS Secret Access Key and signing method. Consult the service documentation for details. - {"__type":"c
  om.amazon.coral.service#InvalidSignatureException","message":"The request signature we calculated does not match th
  e signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation fo
  r details."}

Steps to Reproduce

  1. Install wpsnapshots in Ubunutu with PHP 7.4
  2. wpsnapshots search t-mobile
  3. See error

Environment information

  • Device: Dell XPS 13
  • OS: Windows 10 Pro

Unable to skip overwriting local snapshot using one line command

Describe the bug

Currently, there is no way to skip overwriting local snapshot use one line command because the --overwrite_local_copy option doesn't accept any value. This option should be able to skip using one line command like --include_db or --include_files.

By the way, this breaks wpacceptance test because of overwriting snapshot issue inside the WPA docker container:

Warning: rmdir(/root/.wpsnapshots/a3f2959614a18989ea365da4d86945f1/): Device or resource busy in /root/.composer/vendor/10up/wpsnapshots/src/utils.php on line 359

IMO, in the WPA context, it's safe to always skip overwriting local snapshots because the latest snapshot is pulled at the creation time of the docker container.

When assigning domains on a multisite, include the blog name as well as the blog ID.

When importing a multisite, the system wants to assign the primary host name as the default domain for each internal site. The notice includes the blog ID, but I might not know which site this ID is mapped to at this step of the process.

Current display:

Replacing URLs for blog 9. Path for blog is /.
Home URL (http://yoursite.test/ might make sense):

Would it be possible to display the sites blogname?

Introduce ability to push/pull database only.

While working with wpsnapshots on a project, I have noticed a need to pull only the database from the snapshot, while leaving the file system the same. There is a way to do this manually (from S3), but it would be nice to have this feature as a part of the wpsnapshots command.

e.g wpsnapshots pull <snapshot-id> --db_only

Show file size when doing search

When doing search for a snapshot, it would be nice to have filesize in the output.
The reason is I need to know how big the snapshot is. So I can estimate how long the download process will be.

Feature Request: Support Azure Storage

This project is awesome but unfortunately our current client is tied to Microsoft's cloud infrastructure so I'm asking if you have considered adding support for Azure Storage? It seems to have an official SDK available for use.

This could also mean wider design decisions to support multiple cloud providers like Google etc. as well or having some kind of system for developers to hook up their own storage system.

Another solution could be to have an option to save the snapshot locally and use that local version instead of the centralized repository. While this lacks the testability between developers it could still be useful for CI/CD pipelines.

Fails to push a snapshot of a codebase that contains the same AWS SDK

Describe the bug

If you try to push a snapshot of a theme that uses the same AWS SDK library, you get an error about duplicate functions and are unable to push a snapshot.

Cannot redeclare Aws\constantly() (previously declared in /opt/wpsnapshots/vendor/aws/aws-sdk-php/src/functions.php:19) in /var/www/html/wp-content/themes/{theme_name}/inc/s3/Aws/functions.php on line 22

Steps to Reproduce

  1. Create a theme locally that loads and uses the same AWS SDK.
  2. Push a snapshot (either database only, code only or code and database) and see the error output in the cli.

Expected behavior

WPSnapshots should run independently of the codebase being pushed.

Environment information

  • Device: MacBook
  • OS: MacOS 10.14.6
  • Browser and version: Chrome Version 92.0.4515.159
  • WordPress version: 5.8

Additional context

Please add a `--project` option

Is your enhancement related to a problem? Please describe.
I'd like to be able to specify all things on the command line. Adding a --project or --slug option would allow me to specify the project slug.

Describe alternatives you've considered
I guess I could use expect

suggestion: move/delete mu-plugins

WPE's platform-specific plugins clog up / ruin the works on a local environment... could be solved by adding mv mu-plugins __mu-plugins when doing a pull

Cannot push/create snapshot

When running wpsnapshots push I get an exception error message:
The "exclude-uploads" option does not exist.

Looking at the code there are some inconsistency using the exclude_uploads vs exclude-uploads.

screen shot 2018-10-07 at 12 26 10 pm

screen shot 2018-10-07 at 12 26 22 pm

Docker container / PHP 7.3 incompatibility with latest WPVIP dev environment

Describe the bug

Using WP Snapshots with the latest VIP Go MU Plugins changes, Automattic/vip-go-mu-plugins@51ccaa3#diff-f689ded77c119b968db89a8c3b868aa245442df4c8711edbe95d59c0a471d834R18, is causing the following error (project name omitted using *):

$ 10updocker wpsnapshots create
✔ Global services are running...
✔ MariaDB has started...
Project Slug (letters, numbers, _, and - only): ****
Snapshot Description (e.g. Local environment): ******* **** **** **** ****** *****
Include files in snapshot? (Y/n) y
Include database in snapshot? (Y/n) y

Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/html/wp-content/mu-plugins/healthcheck/class-healthcheck.php on line 18

That line in particular is using a coding convention introduced in PHP 7.4 and above: https://www.php.net/manual/en/language.types.declarations.php.

Using the following with the Docker CLI confirms that the WP Snapshots container is running PHP 7.3.x, which will be the cause of the error:

$ docker exec -it [container-name] /bin/bash
root@c67ea627f75b:/opt/wpsnapshots# php --version
PHP 7.3.9 (cli) (built: Sep 12 2019 10:57:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.0beta1, Copyright (c) 2002-2018, by Derick Rethans

Note: I previously created a ticket here, 10up/wp-local-docker-v2#305, incorrectly.

Steps to Reproduce

  1. Create a new environment using the 10updocker CLI.
  2. Add the vip-go-mu-plugins repository to the wp-content/mu-plugins directory, using the guide here: https://docs.wpvip.com/how-tos/local-development/#h-step-2-add-vip-go-mu-plugins.
  3. Run 10updocker wpsnapshots create.

Screenshots, screen recording, code snippet

No response

Environment information

  • Device: bespoke PC build
  • OS: Ubuntu 20.04.4 LTS
  • Docker Version: 20.10.16, build aa7e414

WordPress information

WordPress: 5.9.3
Themes: custom
Plugins:

  • Fieldmanager | Version 1.5.0 by Alley
  • Pardot | Version 1.5.7 by Salesforce
  • Save and Share Cart for WooCommerce | Version 1.0
  • WooCommerce | Version 6.5.1 by Automattic
  • WooCommerce Shipping & Tax | Version 1.26.0 by WooCommerce
  • Yoast Duplicate Post | Version 4.4 by Enrico Battocchi & Team Yoast

Code of Conduct

  • I agree to follow this project's Code of Conduct

Update Mechanism

Do we have a mechanism to alert users about when updates are made? I recently found out that I was running a pretty old version of snapshots.

Can't find WordPress install if WordPress core files are installed in a sub-directory

I inherited a project that has a composer.json file at the root of the repo, which when ran, will download WordPress into a wp directory, as well as clone all needed plugins and the theme, into a wp-content directory. So we run core WordPress files out of the wp directory and then set a config in wp-config.php to use our root wp-content directory instead of the one in wp/wp-content.

When trying to run the wpsnapshot command here, it tells me it's not a WordPress install. Looking at the code, this error happens when the wp-settings.php file can't be found, which in our case that file is in the wp directory, not within the root.

I tried moving that file up, just for testing, and that gets past the initial issue but causes other issues. Wasn't sure if there was a way to run wpsnapshots in a setup like this or if this is just a unique edge case that won't work.

--no_scrub flag causing an error

Error is: Could not create .wpsnapshots/SNAPSHOT_ID/meta.json..

It happens while using the --no_scrub while push.

Full response:

Setup repository: test
Project Slug (letters, numbers, _, and - only): test
Snapshot Description (e.g. Local environment): test
Bootstrapping WordPress...
Testing MySQL connection.
Getting WordPress tables...
Exporting database...
Saving file back up...
Compressing files...
cd '/var/www/html/wp-content'/ && tar  -zcvf /home/wpsnapshots/.wpsnapshots/8ac437c5f8b3bf2f4aa0a79c55ce008e/files.tar.gz .
Compressing database backup...
Could not create .wpsnapshots/SNAPSHOT_ID/meta.json.
(node:12792) UnhandledPromiseRejectionWarning: Error: Command failed: docker-compose exec wpsnapshots /snapshots.sh push --no_scrub -vvv
    at checkExecSyncError (child_process.js:601:13)
    at execSync (child_process.js:641:13)
    at exec_command (C:\www\Internal\underdev-helper\bin\dsnap.js:16:2)
    at snapshot (C:\www\Internal\underdev-helper\bin\dsnap.js:67:19)
    at <anonymous>
(node:12792) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:12792) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

Multisite User Scrubbing

Describe the bug
When running wpsnapshots push on a multisite installation an error occurs "mysqldump: Couldn't find table: "wp_2_users_temp"" at the Exporting database... \n Scrubbing users... step. WP Multisite doesn't have individual wp_users tables per site, so attempting to fill wp_2_users_temp from wp_2_users is an invalid operation.

Steps to Reproduce

  1. Run wpsnapshots push on a multisite installation
  2. Fill out the snapshot information as required
  3. Include files in snapshot? N
  4. include database in snapshot? Y
  5. Wait for export to begin and validate if it completes or not.

Expected behavior
Upon running the steps above, I expected WP Snapshots to return the newly created snapshot ID containing the exported and scrubbed database for the multisite installation.

Screenshots
Screen Shot 2020-07-22 at 12 09 57 PM

Environment information

  • Device: Macbook Pro
  • OS: macOS Mojave 10.14.6
  • WordPress version: 5.4.2
  • Site Health Info:

Additional context
This is occurring from WP Local Docker V2 (2.7) on a WP Multisite Subdirectory installation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.