Title: Sync users from production and development environments using wp cli
Last modified: February 25, 2019

---

# Sync users from production and development environments using wp cli

 *  [warrior7089](https://wordpress.org/support/users/warrior7089/)
 * (@warrior7089)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/sync-users-from-production-and-development-environments-using-wp-cli/)
 * I want to sync users registered at production environment to development environment.
 * Using the below command sequence for this:
 * 1) Find max user id at the target dev environment using:
 * `wp user list --role='customer' --orderby=ID --order=asc | awk -v max=0 'FNR 
   == 1 {{next}} {{if($1>max){{want=$1; max=$1}}}}END{{print want}}'`
 * 2) Export users whose id is larger than the max user id from 1) to csv on the
   source production env.
 * `wp user list --fields=ID,user_login,user_email,user_pass,user_registered --role
   ='customer' --orderby=ID --order=asc --format=csv --user={root_user} --path={
   wp_path} --ssh={usr}@{host}:{port} | awk 'FNR == 1 {{next}} $1+0>{max_user_id}{{
   print ;}}'`
 * 3) download the csv file from production to dev env.
 * 4) import the csv to target dev env
 * `wp user import-csv /tmp/users_to_sync.csv --skip-update --user={user} --path
   ={path}`
 * However, there’s an issue that passwords are exported as hashed. After successful
   step 4, imported user can’t login on the dev. env.
 * How to sync users correctly if it’s possible at all using wp-cli?
    Is downloading
   _users_ and _users\_meta_ tables enough? Maybe it’s simplicity overweighs the
   complexity of syncing users using wp cli?

The topic ‘Sync users from production and development environments using wp cli’
is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 0 replies
 * 1 participant
 * Last reply from: [warrior7089](https://wordpress.org/support/users/warrior7089/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/sync-users-from-production-and-development-environments-using-wp-cli/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
