• We have a client who makes the same update to dozens of sites. They way I’ve been handling it is to build one page, export to an XML file, then import the XML file using scp, then SSh into each site to run wp import.

    I’d like to run a bash script to do this but I can’t seem to get it to work. My code is:

    #!/bin/bash
    
    for i in "$@"
        do
            echo ""
            echo "Starting: $i"
            ssh -oStrictHostKeyChecking=accept-new "$i@$i.ssh.wpengine.net" 'wp import ~/sites/$i/import.xml --authors=skip; wp cache flush; exit;'
            echo "Done with $i"
            echo ""
    done
    

    I should be able to run this through terminal by using ./script.sh environment1 environment2 ... but it does not work. It will display “starting import process” and exit with no confirmation.

    Is there another way to do this I’m not aware of?

    • This topic was modified 4 years, 7 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 1 replies (of 1 total)
  • @etindle

    Can you kick this off using the -x ?
    Depending on what version you are running, maybe we can output in verbose mode and get some more info back.

Viewing 1 replies (of 1 total)
  • The topic ‘Importing to multiple sites with bash script and WP CLI’ is closed to new replies.