Skip to content

Database update

Christian Boxdörfer edited this page Mar 14, 2021 · 5 revisions

For FSearch to find the files/folders you're looking for it's necessary to keep the database up to date with the filesystem.

Therefore there are currently multiple ways how to update the database:

  • Manually: At any time you can update the database manually from the menu (File -> Update Database) or via Shift + Ctrl + r

  • At startup: With Preferences -> Database -> Update database on start the database will be automatically updated each time you start FSearch

  • Periodically:

    • As long as FSearch is running you can have it periodically update the database according to the Preferences -> Database -> Update every X hour(s) and Y minute(s) setting. Once you exit FSearch this setting won't have any effect.
    • If you want to update the database in the background, even when FSearch is not running, you can use tools like cron or systemd timers to periodically execute fsearch --update-database. See below for a short explanation how to do it.

Periodically update database with systemd timer

First you need to create a systemd unit so systemd knows how to execute a database update. In the command line enter the following:

systemctl --user edit --force --full fsearch_update_database.service

This will open your editor with an empty document where you want to paste the following:

[Unit]
Description=FSearch - Update database

[Service]
ExecStart=fsearch --update-database

[Install]
WantedBy=default.target

Once you saved the document and closed the editor the systemd unit will be installed for your user account. For a quick test you can manually launch it with:

systemctl --user start fsearch_update_database.service

When you have the FSearch window open at the same time you should see that the UI will now show that an update is taking place. Alternatively journalctl --user -u fsearch_update_database.service will give you the log of the last command.

Now you need to tell systemd how to periodically launch the update (i.e. create a systemd timer), in order to do so enter the following in the command line:

systemctl --user edit --force --full fsearch_update_database.timer

and enter the following content in the empty document:

[Unit]
Description=FSearch - Periodically update database

[Timer]
OnBootSec=10min
OnUnitActiveSec=30min

[Install]
WantedBy=basic.target

OnBootSec=10min means that the database update will launch the first time 10 minutes after the system booted and OnUnitActiveSec=30min means that from then on the database will be updated every 30minutes. You can customize those values according to your preference. Note that a database update causes a certain amount of data to be written (~100MB for every 2 million files in the database), hence updating too frequently might have a significant effect on the wear level of certain storage devices (cheaper SSDs, USB sticks, ...). After saving that document and closing the editor the timer is installed for your user account. In order to enable it enter:

systemctl --user enable --now fsearch_update_database.timer

That's it, now the database will be updated periodically in the background.

Clone this wiki locally