Backups
LikeKnocknoc allkeeps technology,its data in files on disk and in a database, so back up both. Backing up the whole machine or VM covers everything on this page.
Which database you are on decides which of the next two sections to follow. Recent installations use PostgreSQL, and installations from before version 8.5 (September 2025) may still be on SQLite. To check, look at /opt/knocknoc/etc/knocknoc.conf for whichever of DBURL (PostgreSQL) or DBFile (SQLite) is set, ignoring the commented-out examples.
If the setup wizard installed HAProxy in front of Knocknoc, keep /etc/haproxy/haproxy.cfg and the certificate it points at under /etc/ssl/private/ as well.
Server: backing up configurationPostgreSQL
The andserver datacan stay running.
sudo install -d -o knocknoc -g knocknoc -m 750 /var/backups/knocknoc
sudo -u knocknoc pg_dump -Fc knocknoc -f /var/backups/knocknoc/knocknoc-db-$(date +%F).dump
sudo tar -czf /var/backups/knocknoc/knocknoc-files-$(date +%F).tar.gz \
-C / opt/knocknoc/etc opt/knocknoc/var/knocknoc.crt opt/knocknoc/var/knocknoc.key
Create the backup directory as shown. The knocknoc user has to be able to write the dump into it.
If your database is paramount,external inor managed (see BYO PostgreSQL), use the casebackup oftooling Knocknocthat thecomes Serverwith andit.
Server: locationsbacking up SQLite
Only for older installations. See Moving from SQLite to capturePostgreSQL areif foundyou below.would like to migrate.
Server
sudo Datainstall resides-d in-o twoknocknoc locations;-g diskknocknoc and-m database.
For/var/backups/knocknoc
Linux, the default installation location issudo /opt/knocknoc/
ForThe Windows,server can stay running. Knocknoc prints the defaultfile installationit locationwrote, isfor example /var/backups/knocknoc/knocknoc_backup_20260731_053828.db. Use this command rather than copying knocknoc.db yourself, which can produce an unusable backup.
Agent: what to back up
sudo tar -czf /var/backups/knocknoc-agent-$(date +%F).tar.gz -C / opt/knocknoc-agent/etc opt/knocknoc-agent/var
OpenBSD (as root)
tar -czf /var/backups/knocknoc-agent-$(date +%F).tar.gz -C / etc/knocknoc-agent var/db/knocknoc-agent
Windows (PowerShell as administrator)
Compress-Archive -Path 'C:\Program Files (x86)\Knocknoc-Agent\knocknoc-agent.conf','C:\Windows\System32\keys.json' -DestinationPath "$env:USERPROFILE\knocknoc-agent-backup.zip"
WithinOn those folders, these sub-folders contain data which should be backed up.
C:\Windows\System32\keys.json, not to the install directory, unless you set KeysFile in the agent configuration.
Restoring a server running PostgreSQL
Install Knocknoc first, ideally the same version the backup came from. See Updates and upgrades.
Stop the server.
sudo systemctl stop knocknoc
Put the Server TLS/SSL keys/certificatesconfiguration and databasecertificate ifback.
sudo SQLitetar (Prior-xzf to/var/backups/knocknoc/knocknoc-files-<date>.tar.gz November-C 2025)/
sudo chown -R knocknoc:knocknoc /opt/knocknoc
Separately, your Postgres database should be backed up. If you are backing up the entire Server machine/VM, this is naturally covered. If you're using a third-party database/database service, ensure that is backed up. However if you are running locally and want to captureRecreate the database periodically, use either pg_dump or pg_basebackup.empty.
Agent
sudo -u postgres dropdb --if-exists knocknoc
sudo -u postgres createdb -O knocknoc knocknoc
For Linux,Load the defaultdump.
sudo location-u isknocknoc pg_restore -d knocknoc /var/backups/knocknoc/knocknoc-db-<date>.dump
Start the server.
sudo systemctl start knocknoc
Restoring a server running SQLite
Stop the server.
sudo systemctl stop knocknoc
Remove the current database and its two companion files.
sudo rm -f /opt/knocknoc/var/knocknoc.db \
/opt/knocknoc/var/knocknoc.db-wal \
/opt/knocknoc/var/knocknoc.db-shm
Copy the backup into place and give it back to the knocknoc user.
sudo cp /var/backups/knocknoc/knocknoc_backup_<timestamp>.db /opt/knocknoc/var/knocknoc.db
sudo chown knocknoc:knocknoc /opt/knocknoc/var/knocknoc.db
sudo chmod 600 /opt/knocknoc/var/knocknoc.db
Start the server.
sudo systemctl start knocknoc
Restoring an agent
sudo tar -xzf /var/backups/knocknoc-agent-<date>.tar.gz -C /
sudo chown -R knocknoc-agent:knocknoc-agent /opt/knocknoc-agent/agent
sudo systemctl restart knocknoc-agent
For Windows,Give the defaultagent installationa locationminute isto C:\Programreconnect Filesbefore (x86)\Knocknoc-Agent\deciding it hasn't worked.
Within
Checking thosethat folders,a theserestore sub-folders contain data which should be backed up.worked
"etc/"Logwhichincontainsto theAgentadminconfigurationportalfile(s)with the credentials you used before the backup, and confirm your users, groups and knocs are listed."var/"OpenwhichAgentscontainsand check each one has been seen recently.
Still Having Issues?
NoteWe thecan orchestrationhelp agentyou doesout, notcontact haveus anat on-disk database.[email protected].