1

I am trying to get backup of DB using following command

php -dmemory_limit=1G bin/magento support:backup:db

It is giving me syntax error:

sh: 2: Syntax error: word unexpected (expecting ")")
Error: Command returned non-zero exit code:
`(/usr/bin/nice -n 15 /usr/bin/mysqldump -uxxxx -hxxxx  -p"xxxx" xxxx --skip-extended-insert  customer_entity customer_entity_varchar customer_address_entity customer_address_entity_varchar customer_grid_flat quote quote_address sales_order sales_order_address sales_order_grid 2>&1 | /usr/bin/php -r 'while ($line=fgets(STDIN)) {
           if (preg_match("/(^INSERT INTO\s+\S+\s+VALUES\s+)\((.*)\);$/",$line,$matches)) {
               $row = str_getcsv($matches[2],",","\x27");
               foreach($row as $key=>$field) {
                   if ($field == "NULL") {
                       continue;
                   } elseif ( preg_match("/[A-Z]/i", $field)) {
                       $field = md5($field . rand());
                   }
                   $row[$key] = "\x27" . $field . "\x27";
               }
               echo $matches[1] . "(" . implode(",", $row) . ");\n";
               continue;
           }
           echo $line;
       };';

I didn't tried this command before and never faced this type of error, can anyone guide me how can I resolve this error?

1

I have not seen support:backup:db command yet.

To take the backup of database, the command i have used is

php -dmemory_limit=1G bin/magento setup:backup --db
  • I will check, will let you know – Shoaib Munir Apr 4 '19 at 7:13
  • It worked. Thanks – Shoaib Munir Apr 5 '19 at 5:01
1

Try to run the below command it is also used for the tacking backups in magento 2

php bin/magento setup:backup --db --code --media

Through this command magento will backup your required data (source_code, database, Media files) to the Magento_root/var/backup directory from there you can download it again & also can rollback if it is needed in future.

Please refer this devdocs.

  • I will check, will let you know – Shoaib Munir Apr 4 '19 at 7:13
  • Thanks for the answer. +1 – Shoaib Munir Apr 5 '19 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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