How to do automated imports
Preparation
First, do this:
Configuration
Then, in the .importer.env-file:
- Add
IMPORT_DIR_ALLOWLIST=/import - Add a value for
FIREFLY_III_ACCESS_TOKEN - Add
NORDIGENorSPECTREcredentials (NORDIGENis used for GoCardless). - Set
CAN_POST_AUTOIMPORT=true - Set
CAN_POST_FILES=true - Set
AUTO_IMPORT_SECRETusing a random string of at least 16 characters. This is used to secure the auto-import endpoint. Visit this page on random.org for inspiration.
And in the Docker Compose file from the installer, mount a local directory to /import in the container:
Run the import once
In the Data Importer, run through the import and download the configuration file. Put the JSON-file in the import folder you created and bound to the container. Be sure to name it config.json. The name can be anything though.
Run another import, automatically
Run the following command:
Where firefly_iii_importer is the container ID, and where config.json is the configuration file from the previous step. This should run the import again.
Make it a cron job
To make this a cron job, run crontab -e and add the following line:
This particular cron job will run on the host system. To make the cron job for the data importer a part of the docker-compose.yml file as well, you'll need to do something more complex.
- Specify the
AUTO_IMPORT_SECRETin your.importer.envfile. This value must be at least 16 characters. Visit this page on random.org for inspiration. - In the code below, replace [AUTO_IMPORT_SECRET] with the same value.
- In the code below, replace [STATIC_CRON_TOKEN] with
STATIC_CRON_TOKENvalue from your.envfile. - Replace the
firefly_iii_cron-container entry in your compose file with the resulting code:
cron_importer:
image: alpine
container_name: firefly_iii_cron
restart: always
command: sh -c "
apk add tzdata
&& ln -s /usr/share/zoneinfo/${TZ} /etc/localtime
&& echo \"0 3 * * * wget -qO- http://app:8080/api/v1/cron/STATIC_CRON_TOKEN;echo\" > /tmp/crontab_tmp
&& echo -e \"40 2 * * * wget -qO - --post-data '' --header 'Accept":" application/json' 'http://importer:8080/autoimport?directory=/import&secret=[AUTO_IMPORT_SECRET]'\" >> /tmp/crontab_tmp
&& crontab /tmp/crontab_tmp
&& rm /tmp/crontab_tmp
&& crond -f -L /dev/stdout"
networks:
- firefly_iii
Portainer uses may also use the following lines. This will make Portainer do the replacement automatically. This will not work on other systems.