Backup all your tables from ZOHO CRM in CSV format


/ Published in: Perl
Save to your folder(s)

fill your username and password


Copy this code and paste it in your HTML
  1. #!/usr/bin/perl
  2. use strict;
  3. use LWP::UserAgent;
  4. my $silent = 0; # set to 1 for no output on stdout
  5. my $logindata = {
  6. 'j_username' => 'fill in your username (email)',
  7. 'j_password' => 'fill in your password',
  8. 'j_remember' => 'on',
  9. };
  10. my $loginurl = 'http://crm.zoho.com/crm/zohologin';
  11. my $backupurl = 'http://crm.zoho.com/crm/ExportEntity.do';
  12. my @backuptables = qw{Users Leads Accounts Contacts Potentials Campaigns Tasks Events Notes Competitors Products PriceBooks Cases Solutions Forecasts Vendors Quotes SalesOrders PurchaseOrders Invoices};
  13.  
  14. my $ua = LWP::UserAgent->new;
  15. $ua->cookie_jar({ file => "cookies.txt" });
  16.  
  17. print qq{get cookie from frontpage...} unless $silent;
  18. my $devnull = $ua->get('http://crm.zoho.com/crm/login.sas'); #get cookie
  19. print qq{done.\n} unless $silent;
  20.  
  21. print qq{login as $$logindata{'j_username'}...} unless $silent;
  22. my $loginresponse = $ua->post($loginurl, $logindata);
  23. print qq{done.\n} unless $silent;
  24.  
  25. foreach my $whichtable (@backuptables) {
  26. print qq{exporting $whichtable.csv...} unless $silent;
  27. my $backupdata = {
  28. 'module' => $whichtable,
  29. };
  30. my $backuptable = $ua->post($backupurl, $backupdata);
  31. open (KI, ">$whichtable.csv");
  32. print KI $backuptable->content;
  33. close (KI);
  34. print qq{done.\n} unless $silent;
  35. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.