Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --overwrite_local_copy flag to pull command #71

Merged
merged 3 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ WP Snapshots revolves around pushing, pulling, and searching for snapshots. WP S

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]
* __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.

Expand All @@ -88,7 +88,7 @@ Documentation for each operation is as follows:

`--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]__
* __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.

Expand Down
9 changes: 7 additions & 2 deletions src/classes/Command/Pull.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected function configure() {
$this->addOption( 'confirm_ms_constant_update', null, InputOption::VALUE_NONE, 'Confirm updating constants in wp-config.php for multisite.' );
$this->addOption( 'include_files', null, InputOption::VALUE_NONE, 'Pull files within snapshot.' );
$this->addOption( 'include_db', null, InputOption::VALUE_NONE, 'Pull database within snapshot.' );
$this->addOption( 'overwrite_local_copy', null, InputOption::VALUE_NONE, 'Overwrite a local copy of the snapshot if there is one.' );

$this->addOption( 'config_db_host', null, InputOption::VALUE_REQUIRED, 'Config database host.' );
$this->addOption( 'config_db_name', null, InputOption::VALUE_REQUIRED, 'Config database name.' );
Expand Down Expand Up @@ -111,7 +112,11 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
}

if ( ! empty( $remote_meta ) && ! empty( $local_meta ) ) {
$overwrite_local = $helper->ask( $input, $output, new ConfirmationQuestion( 'This snapshot exists locally. Do you want to overwrite it with the remote copy? (y/N) ', false ) );
if ( empty( $input->getOption( 'overwrite_local_copy' ) ) ) {
$overwrite_local = $helper->ask( $input, $output, new ConfirmationQuestion( 'This snapshot exists locally. Do you want to overwrite it with the remote copy? (y/N) ', false ) );
} else {
$overwrite_local = true;
}
}

if ( empty( $local_meta ) && ! empty( $remote_meta ) ) {
Expand Down Expand Up @@ -333,7 +338,7 @@ protected function execute( InputInterface $input, OutputInterface $output ) {

if ( empty( $confirm ) ) {

$confirm = $helper->ask( $input, $output, new ConfirmationQuestion( 'Are you sure you want to do this? This is a potentially destructive operation. You should run a back up first. (y/N) ', false ) );
$confirm = $helper->ask( $input, $output, new ConfirmationQuestion( 'The snapshot is ready, please, can you confirm that you want to apply it? It is a potentially destructive operation, please, run a back up first. (y/N) ', false ) );

if ( ! $confirm ) {
return 1;
Expand Down