1. Opening Problem Statement
Meet Sarah, a project manager at a growing tech startup. Every month, she faces the tedious task of manually exporting detailed reports from Clockify to keep a backup of all tracked hours. This manual process takes her several hours, involves downloading JSON reports, renaming files systematically, and uploading them to the company’s GitHub repository. Occasionally, she misses exporting a month’s data or overwrites files, leading to inaccurate historical records, causing confusion during audits and client billing reviews.
For Sarah, these mistakes waste not only time—roughly 4 hours monthly—but also risk financial discrepancies that could cost the company thousands in potential billing errors and damaged client trust. Clearly, there must be a way to automate this monthly backup process reliably and accurately.
2. What This Automation Does
When this workflow runs, it automates Sarah’s entire backup routine of Clockify monthly detailed reports into a GitHub repository. Here’s what happens step-by-step:
- Automatically triggers daily: The workflow runs on a schedule (default: 5 AM) to check for new reports.
- Fetches the first available Clockify workspace ID: So it knows which workspace’s data to access, even if settings change.
- Generates date ranges for the last three months: Creates a dynamic scope so Sarah always backs up current plus previous two months’ data.
- Requests detailed monthly reports from Clockify’s API: Pulls all time entries within each month’s date range.
- Checks if the report file already exists in GitHub: Avoiding duplicate backups and enabling updates if data changes.
- Compares new data with existing backup files: To only update GitHub if there are any changes in the report content.
- Creates or updates JSON report files in GitHub: Backups are kept historical and accurate, ensuring reliable audit trail.
- Stops the process with error message if something goes wrong: Clear feedback for troubleshooting.
Overall, this saves Sarah at least 3 hours each month and reduces manual errors to zero, ensuring her company’s billing data integrity stays intact.
3. Prerequisites ⚙️
- Clockify account with API access enabled 🔐
- GitHub repository with write access to store backups 📁
- n8n account to run this automation workflow 🔌
- Clockify API credentials configured in n8n 🔑
- GitHub API credentials configured in n8n 🔑
Optional: Self-host your n8n instance for complete control over your data and automation by following guides like on Hostinger’s n8n hosting tutorial.
4. Step-by-Step Guide
Step 1: Set up the Scheduled Trigger to Run Daily
Navigate to the Schedule Trigger node. Set it to run once daily at 5 AM to automate regular backup checks. This timing helps avoid working hours and ensures fresh data early each day.
This node initiates the data flow to retrieve workspace and report information when triggered.
Step 2: Retrieve the First Clockify Workspace ID
Next, open the Get first workspace node. This Clockify node pulls the first workspace available under your account. It requires your Clockify API credentials already connected to n8n.
The retrieved workspace ID is stored in the Globals node for use throughout the workflow.
Step 3: Define Global Variables
In the Globals Set node, assign values like workspace_id (from step 2), github_repo.owner, and github_repo.name. Replace these with your GitHub username or organization and repository name where backups will be stored.
This centralizes configuration variables for easier maintenance.
Step 4: Set the Month Indexes for Backup Scope
Open the Set month indexes node. Here an array [0,1,2] is defined, representing the current month and the previous two months.
This gives the workflow a dynamic scope to back up three months of detailed reports automatically.
Step 5: Split Month Indexes to Process Individually
The Split Out indexes node takes the array from the previous step and splits it into individual month indexes. This facilitates sequential processing for each month in separate workflow runs in one execution.
Step 6: Set Date Intervals for Each Month
The Set intervals node uses the current date minus the month index to calculate the start and end dates of each month in ISO format. It also generates a dynamic reportName, e.g., detailed_report_2024-06, for naming backup files consistently.
Step 7: Request the Detailed Monthly Report from Clockify
This critical step triggers an HTTP Request node called Get detailed monthly report. It submits a POST request to Clockify’s reports API endpoint, providing the date range and requesting a JSON export of all time entries.
Example payload:
{
"dateRangeStart": "2024-03-01T00:00:00Z",
"dateRangeEnd": "2024-03-31T23:59:59.999Z",
"detailedFilter": {"page":1, "pageSize":50},
"exportType": "json"
}The response contains detailed time entry data for the specified month.
Step 8: Check if Report File Exists in GitHub
Using the Check if file exists in GitHub node, the workflow queries your GitHub repository for the report file using the generated reportName path. This helps to decide whether to create a new file or update an existing one.
If the file is not found, the workflow routes to create the file. If found, it compares the existing file’s content with the new data.
Step 9: Extract Existing GitHub File Content for Comparison
If report exists, the Extract from File node parses the JSON content from GitHub into workable data.
Step 10: Prepare New Data for Comparison
The Point to new data Set node isolates the new time entries array obtained from Clockify API response to prepare for comparison.
Step 11: Compare the New and Existing Report Data
The Compare Datasets node compares the two arrays (new vs existing time entries) based on a matched data field to determine changes.
Step 12: Update or Create GitHub Backup File
If differences are found, the workflow moves to the Update file in GitHub node to overwrite the old report file with the new data.
If the file does not exist, a branch routes to the Create file in GitHub node to make a new JSON backup.
Step 13: Filter Out Empty Reports
Before creating a report file, the Skip empty reports filter node validates that there is actual time entry data to save. If empty, it prevents unnecessary file creation.
Step 14: Stop Workflow on Errors
Any errors such as missing files or API issues trigger the Stop and Error node, which halts the workflow and outputs the error message for debugging.
5. Customizations ✏️
- Expand Backup Scope: Modify the Set month indexes node’s array to
[0,1,2,3,4]to include five months instead of three. - Change Backup Time: Adjust the Schedule Trigger node to run at any preferred hour or frequency, including weekly or monthly.
- Use Different GitHub Repo: Update the repository owner and name in the Globals node to back up reports to another repository or organization.
- Increase API Page Size: Modify the Get detailed monthly report HTTP node’s JSON body
pageSizeparameter to a higher value for more extensive monthly data retrieval. - Add Notification: Insert an email or Slack node after the GitHub update to notify Sarah or team about backup status.
6. Troubleshooting 🔧
Problem: “could not be found” error when checking GitHub file existence
Cause: The file path or repository info is incorrect or the file truly does not exist.
Solution: Verify the Globals node’s repo owner/name values and ensure the path reports/detailed_report_YYYY-MM matches the configured structure.
Problem: API rate limits or authentication errors when calling Clockify API
Cause: Invalid or expired Clockify API credentials.
Solution: Refresh your Clockify credentials in n8n, and check that the connected API key is valid and has permissions for workspace access.
Problem: Workflow fails to update or create files in GitHub
Cause: Insufficient GitHub API permissions.
Solution: Make sure your GitHub token used in n8n has write repo permissions and the correct scopes enabled.
7. Pre-Production Checklist ✅
- Confirm Clockify API credentials are correctly configured and authorized.
- Verify GitHub repository owner and name are set correctly in the Globals node.
- Run a test execution for the current month and verify JSON report files are created in GitHub under the right path.
- Check logs for any errors and fix as needed before scheduling the workflow.
- Backup existing GitHub report files if replacing an older manual process to avoid data loss.
8. Deployment Guide
Once tested, activate the Schedule Trigger node to enable the automation to run at your set daily time.
Monitor workflow executions initially within n8n to ensure reports are backing up as expected. Check GitHub repository to confirm files update monthly and error nodes are not triggered.
9. FAQs
Q: Can I use a private GitHub repository for backups?
A: Yes, ensure your GitHub API credentials have the necessary permissions for private repos.
Q: Does this workflow consume a lot of API credits?
A: The workflow uses a few API calls daily and monthly report requests but should stay within typical free tier limits for Clockify and GitHub.
Q: Is my data secure in this backup process?
A: Yes, API communications are secured with tokens, and storing in your private GitHub repo keeps backups under your control.
10. Conclusion
By following this guide, you’ve automated backing up your Clockify monthly detailed reports to GitHub seamlessly. This workflow eliminates Sarah’s manual 4-hour monthly task and prevents backup omissions or errors. Now your time tracking data is historically accurate, easy to audit, and safely stored with version control.
Next, consider extending this workflow to notify your team on completion via Slack or email, or automate report parsing and summaries for quick insights right from GitHub.
Leveraging n8n’s Clockify and GitHub nodes in this targeted automation empowers you with reliable data backups and peace of mind without the manual hassle.