Housekeeping
NetBox includes a housekeeping management command that should be run nightly. This command handles:
- Clearing expired authentication sessions from the database
- Deleting changelog records older than the configured retention time
- Deleting job result records older than the configured retention time
- Check for new NetBox releases (if
RELEASE_CHECK_URLis set)
This command can be invoked directly, or by using the shell script provided at /opt/netbox/contrib/netbox-housekeeping.sh.
Scheduling
Using Cron
This script can be linked from your cron scheduler's daily jobs directory (e.g. /etc/cron.daily) or referenced directly within the cron configuration file.
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeepingOn Debian-based systems, be sure to omit the .sh file extension when linking to the script from within a cron directory. Otherwise, the task may not run.
Using Systemd
First, create symbolic links for the systemd service and timer files. Link the existing service and timer files from the /opt/netbox/contrib/ directory to the /etc/systemd/system/ directory:
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.service /etc/systemd/system/netbox-housekeeping.service
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.timer /etc/systemd/system/netbox-housekeeping.timerThen, reload the systemd configuration and enable the timer to start automatically at boot:
sudo systemctl daemon-reload
sudo systemctl enable --now netbox-housekeeping.timerCheck the status of your timer by running:
sudo systemctl list-timers --allThis command will show a list of all timers, including your netbox-housekeeping.timer. Make sure the timer is active and properly scheduled.
That's it! Your NetBox housekeeping service is now configured to run daily using systemd.
Error Reporting
NetBox supports native integration with Sentry for automatic error reporting. To enable this functionality, set SENTRYENABLED to True and define your unique ...
Replicating NetBox
NetBox employs a PostgreSQL database, so general PostgreSQL best practices apply here. The database can be written to a file and restored using the pgdump an...