How to schedule an automatic HubSpot export to CSV
The short answer
HubSpot's Export button in a contacts or deals view gives you a CSV once, when someone clicks it. HubSpot doesn't offer a setting that runs that export every week. Your options are:
1. Recurring report emails. These are built in, but only work for report data.
2. A small script that calls the HubSpot API and runs on a timer. It's free and works well, but someone has to own it.
3. A dedicated backup or export app from the HubSpot App Marketplace.
Each one is covered below, along with the problems you'll hit.
Option 1: Recurring report emails (built in)
HubSpot can email a report on a Daily, Weekly or Monthly schedule with a data file attached. According to HubSpot's knowledge base:
1. Go to Reporting > Reports and open the report.
2. Click Actions > Share via and choose email.
3. Change the frequency from send-once to recurring and pick a schedule.
4. In Attach downloadable file, choose a file type. If you skip this, the email shows a picture of the report and has no data file.
Pitfalls
- Recurring sends can only go to HubSpot users. You can't send them to a shared mailbox or straight to Google Drive.
- You get the report, not the full records. Any property that isn't in the report won't be in the file.
- The file arrives as an email attachment, so someone still has to save it somewhere.
This works if you want a weekly pipeline summary. It doesn't work as a backup.
Option 2: A scheduled script (Google Apps Script)
If your team uses Google Workspace, Apps Script can call HubSpot's API every week and save a CSV in a Drive folder. You don't need a server.
Step 1: Create a token. In HubSpot, create a private app under Settings > Integrations > Private Apps (HubSpot has moved and renamed this screen over time). Give it read-only scopes for the objects you need, such as crm.objects.contacts.read and crm.objects.deals.read, then copy the access token.
Step 2: Create the script. Go to script.google.com and create a project. Under Project Settings > Script properties, add HUBSPOT_TOKEN. Then paste in:
`js
function exportHubSpotDeals() {
const token = PropertiesService.getScriptProperties().getProperty('HUBSPOT_TOKEN');
const props = ['dealname', 'amount', 'dealstage', 'closedate'];
const rows = [['id'].concat(props)];
let after = null;
do {
let url = 'https://api.hubapi.com/crm/v3/objects/deals?limit=100&properties=' + props.join(',');
if (after) url += '&after=' + after;
const res = JSON.parse(UrlFetchApp.fetch(url, {
headers: { Authorization: 'Bearer ' + token }
}).getContentText());
res.results.forEach(r => rows.push([r.id].concat(props.map(p => r.properties[p] || ''))));
after = res.paging && res.paging.next ? res.paging.next.after : null;
} while (after);
const csv = rows.map(r => r.map(v => '"' + String(v).replace(/"/g, '""') + '"').join(',')).join('\n');
const name = 'hubspot-deals-' + Utilities.formatDate(new Date(), 'UTC', 'yyyy-MM-dd') + '.csv';
DriveApp.getFolderById('YOUR_FOLDER_ID').createFile(name, csv, MimeType.CSV);
}
`
Step 3: Schedule it. In the editor, open Triggers, add a time-driven trigger and choose a weekly timer, for example Sunday night.
To export contacts, copy the function and change deals to contacts and the properties to fields like email, firstname, lastname and company.
Pitfalls
- Pagination. The API returns results in pages. Without the
afterloop above, you'd only save the first page and wouldn't notice anything was missing. - Internal property names. The API uses names like
dealstage, not the labels you see in HubSpot. Deal stages come back as IDs, not stage names, so you'll need to map them yourself if you want readable labels. - Large portals. Apps Script has execution time limits. If you have a lot of records, use HubSpot's exports API instead. You start an export with
POST /crm/v3/exports/export/async, then checkGET /crm/v3/exports/export/async/tasks/{exportId}/statusuntil it reportsCOMPLETE. That endpoint needs thecrm.exportscope, and the guide says a Super Admin has to grant it. - Ownership. Scripts break quietly when the person who wrote them leaves or their token is revoked. Write down who owns it, and check the folder once a month.
Option 3: A Marketplace app or automation tool
General automation tools such as Zapier and Make can connect HubSpot to Google Sheets or Drive. They're usually built to react to events, like "new deal created", rather than take a full weekly snapshot, so look carefully at how a scheduled full export would work before you rely on one. The HubSpot App Marketplace also lists backup and export apps that install directly into your portal.
Which one to pick
| You need | Use |
|---|---|
| A weekly pipeline summary for managers | Recurring report email |
| A full weekly copy, with someone technical in-house | Apps Script plus the API |
| A full weekly copy that nobody has to maintain | A Marketplace export app |
Whichever option you choose, test a restore. Open the CSV, check that the row count matches HubSpot, and confirm the columns you'd need to rebuild a deal are actually there.
We're building Sundayfile, a HubSpot Marketplace app that will put a weekly CSV of your contacts and deals in Google Drive automatically. It's coming soon. It's one option among those above.