Ghostbudget
Sync Actual Budget accounts with Ghostfolio
Install / Use
/learn @johnkrzywanek/GhostbudgetREADME
GhostBudget
GhostBudget is a Node.js application that synchronizes account balances between Actual Budget and Ghostfolio. It automatically fetches your account balances from Actual Budget and updates the corresponding accounts in Ghostfolio. Big thanks to authors and contributors from both projects!
Features
- Automatic authentication with both Actual Budget and Ghostfolio
- Configurable account mapping between the two systems
- Automatic balance conversion from Actual Budget's format to Ghostfolio's format
- Detailed logging for monitoring and troubleshooting
- Error handling with helpful messages
Prerequisites
- Node.js (v14 or higher recommended)
- An Actual Budget server instance
- A Ghostfolio instance
- Access tokens/credentials for both services
The script will:
- Fetch account balances from Actual Budget
- Authenticate with Ghostfolio
- Get the current account list from Ghostfolio
- Map accounts between the two systems
- Update balances in Ghostfolio
Installation
- Clone the repository:
git clone https://github.com/johnkrzywanek/ghostbudget.git
cd ghostbudget
- Install dependencies:
npm install
- Create configuration files:
cp .env.example .env
cp config.json.example config.json
- Edit the
.envfile with your credentials and settings - Edit the
config.jsonfile with your account mappings
Configuration
Environment Variables (.env)
ACTUAL_BUDGET_URL: URL of your Actual Budget serverACTUAL_BUDGET_PASS: Your Actual Budget server passwordACTUAL_BUDGET_SYNC_ID: Your budget's sync IDACTUAL_BUDGET_DATA_DIR: Directory for Actual Budget dataGHOSTFOLIO_URL: URL of your Ghostfolio instanceGHOSTFOLIO_TOKEN: Your Ghostfolio access token
Account Mapping (config.json)
The config.json file maps accounts between Actual Budget and Ghostfolio. Example structure:
{
"accounts": [
{
"ghostfolioName": "Exact name of account in Ghostfolio",
"actualBudgetName": "Exact name of account in Actual Budget"
}
]
}
Note: Account names must match exactly with the names in both systems.
Usage
Running the Sync
You can run the synchronization with different log levels:
# Normal operation (info level logs)
npm run sync
# With debug information
LOG_LEVEL=debug npm run sync
# Only show errors
LOG_LEVEL=error npm run sync
Log Levels
error: Only logs errorswarn: Logs errors and warningsinfo: Normal operational messages (default)debug: Detailed debugging information
Log Files
Logs are written to:
logs/combined.log: Contains all logslogs/error.log: Contains only error logs- Console: Shows colored output for development
Automated Execution
Using Cron
Add this to your crontab to run it automatically:
# Run every hour
0 * * * * cd /path/to/ghostbudget && LOG_LEVEL=info /usr/local/bin/npm run sync
Using Systemd
Create a service file (/etc/systemd/system/ghostbudget-sync.service):
[Unit]
Description=Sync Actual Budget with Ghostfolio
After=network.target
[Service]
Type=oneshot
WorkingDirectory=/path/to/ghostbudget
Environment=LOG_LEVEL=info
ExecStart=/usr/local/bin/npm run sync
User=youruser
[Install]
WantedBy=multi-user.target
Create a timer file (/etc/systemd/system/ghostbudget-sync.timer):
[Unit]
Description=Run Ghostbudget sync every hour
[Timer]
OnBootSec=5min
OnUnitActiveSec=1h
Unit=ghostbudget-sync.service
[Install]
WantedBy=timers.target
Enable and start the timer:
sudo systemctl enable ghostbudget-sync.timer
sudo systemctl start ghostbudget-sync.timer
Balance Conversion
The application automatically handles balance conversion between the two systems:
- Actual Budget stores balances as integers (e.g., 100012 for $1,000.12)
- GhostBudget converts these to decimal format before sending to Ghostfolio (e.g., 1000.12)
Error Handling
The application includes comprehensive error handling:
- Validates required environment variables
- Verifies account mappings exist in both systems
- Provides detailed error messages for troubleshooting
- Logs all operations for debugging
Development
Adding New Features
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Troubleshooting
Common issues and solutions:
-
Connection Issues
- Verify your Actual Budget and Ghostfolio servers are running
- Check URLs in
.envfile - Verify network connectivity
-
Authentication Errors
- Verify your access tokens/credentials
- Check if tokens have expired
- Ensure proper permissions are set
-
Account Mapping Issues
- Verify account names match exactly
- Check for typos in config.json
- Ensure accounts exist in both systems
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or need support, please create an issue in the GitHub repository.
