We have two magento installation for the same shop. One is named live and the other is named staging.

How can I mirror all products and categories from live with staging?

Do I have to export / import the whole database?

  • do you want same copy as live site into staging, right? or you want just category and product data not other data? Commented Sep 7, 2018 at 14:26
  • I want categories, products, cms pages, cms blocks etc., basically everything without customers.
    – Black
    Commented Sep 7, 2018 at 17:51

2 Answers 2


I'd take a look at Magerun's db:dump functionality.

You can run something like n98-magerun.phar db:dump --strip="@development" which will provide a DB dump with customer/order/log data stripped from the SQL export but still include all product/category/core tables.

What I usually run is n98-magerun.phar db:dump --strip="@development" --compression=gzip /tmp/database.sql.gz so it's compressed and then put in /tmp/ to ensure it doesn't go to Magento's public directory.

More information on Magerun's db:dump functionality & installation can be found here (There is also a Magento 2 version here)


With this method you will have to update your base URLs and other config once you import the SQL to your staging environment but you can use Magerun to set the config values after the import.


Create a new admin user staging/password1

n98-magerun.phar admin:user:create staging [email protected] password1 Example User

Amend default base_urls

n98-magerun.phar config:set web/unsecure/base_url http://staging.example.com/
n98-magerun.phar config:set web/secure/base_url http://staging.example.com/
  • But I think this will also delete all admin users. There are many admins and devs working on staging though, do I have to create them again??
    – Black
    Commented Sep 7, 2018 at 17:49
  • @Black Actually, admin stripping was added in version 1.100.0 of Magerun. If you download a version below this you won't get this feature. Version 1.99.0 release here - github.com/netz98/n98-magerun/archive/1.99.0.tar.gz Commented Sep 10, 2018 at 9:00
  • is there a way to do this without BE admins getting deleted? I just imported my live db with your instructions to staging, but no one can login to the backend anymore.
    – Black
    Commented Sep 10, 2018 at 10:58
  • 1
    @Black See my post above your comment. Basically you'll need to delete Magerun on both your staging and production environments and download the 1.99.0 version which can be found here here - github.com/netz98/n98-magerun/archive/1.99.0.tar.gz - This version doesn't include the admin_users table getting stripped on export. Hope that helps! Commented Sep 10, 2018 at 11:06
  • I just tried it, but the admin_users table is still getting stripped...
    – Black
    Commented Sep 10, 2018 at 11:24

According to your requirement you need to do this things.

  1. Copy the database from live to staging.

  2. Create one script in magento root with this code. (Ex : test.php)

    $mageFilename = 'app/Mage.php';
    if (!file_exists($mageFilename)) {
              echo $mageFilename." was not found";
    require_once $mageFilename;
    Mage::register('isSecureArea', true);
        $customers = Mage::getModel("customer/customer")->getCollection();
        foreach ($customers as $customer) {
        echo "Customer Delete Sucessfully";
    } catch (Exception $e) {
       echo $e->getMessage();
  3. Now run this file from browser. (Ex : www.domain.com/test.php)

  • Is it not possible to just import the categories, products and cms pages? Do I really have to import the whole database?
    – Black
    Commented Sep 8, 2018 at 19:16
  • Then you need to find or create custom solution to import only those data. But easy way I already specify above. Commented Sep 9, 2018 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.