We've done a lot of refactoring with 4.2 that changes the behavior of the import/export scripts (and fixes some bugs that prevented it from working in earlier releases).
It's now better integrated with the re-designed cli.php.
Here are the new usage directions for 4.2:
* php bin/csv/import.php -e <entity> --file /path/to/csv/file [ -s site.org ]
* e.g.: php bin/csv/import.php -e Contact --file /tmp/import.csv
* php bin/csv/export.php -e <entity> [ --field=value --field=value ] [ -s site.org ]
* e.g.: php bin/csv/export.php -e Contact --firstname.lastname@example.org -s mygroup.org
The export doesn't export all the fields in Version 4.2.2
With a standard install I first exported the Custom Group Table:
php export.php -e CustomField Tag > custom_field.csv
I then re-imported it:
php import.php -e CustomGroup --file C:\Exports\custom_group.csv
When checking the before / after copies of the Custom Group Table (and the export file) I noticed that the following fields had not been included in the export (and hence, the values in these fields could not be re-imported, and so were lost):
With 4.2, there's a change in how parameters are passed using these tools. You need to add columns to the CSV itself. The parameter name goes in the header, and the value in the record.
Here's a snippet I used to remove all the contacts from a database while keeping the settings, custom fields, etc. intact. it adds a column called "skip_undelete" with a vaue of "1" for each record:
drush civicrm-sql-query "SELECT id from civicrm_contact WHERE id > 1;" > test.csv sed -i '1 s/.*/&,skip_undelete/' test.csv sed -i '2,$ s/.*/&,1/' test.csv php /var/www/<mysite>/sites/all/modules/contrib/civicrm/bin/csv/delete.php -e Contact -u civi.admin -p <mypass> --file=<mypath>/test.csv
I ran into that issue. This is the potential cause: http://bit.ly/1oo2u5Q . Not sure if this export method is still supported so be careful.
I'm using an older version of CiviCRM (4.6) with Drupal 7 on Linux and until now I've not really used the command line stuff for CiviCRM, only for Drupal.
But I now need to do exports & imports of contacts etc to & from CiviCRM and so I've installed Drush & got it working. I've tried doing an export with the export.php script with Drush and can manipulate the search results to some degree. But for some reason if only exports the first 26 rows ... is the a parameter that I should be using to get the full rowcount?
Also, where is the best place to get a more detailed list of examples, list of possible parameters etc?