Backups
This page explains where your server's backups go, how to make and restore them from the command line, and how to copy them to another computer.
On this page
Your server makes a backup before every update, and whenever you ask in Settings → Backups
(Backups). Backups go in /var/lib/nifty-backups, beside the data in /var/lib/nifty. Copy them to
another computer too, because a backup on the same disk won't survive if the disk fails.
Back up from the command line
Run these commands as the server's user, while Nifty is running.
sudo -u nifty /usr/local/bin/nifty backup
sudo -u nifty /usr/local/bin/nifty backup list
nifty backup finds the service's data and backup folders by itself. For other installs, pass --data, and pass
--backup-dir if you chose another folder. If it can't read the service's settings, it says so and names the data
directory it's using.
Restore
- Find the backup's ID with
sudo -u nifty /usr/local/bin/nifty backup list. - Stop Nifty with
sudo systemctl stop nifty. - Restore the backup with
sudo -u nifty /usr/local/bin/nifty backup restore 20261013-142233-before_update. - Start Nifty with
sudo systemctl start nifty.
Nifty first backs up the data it replaces, as Before restore. If that can't be done, such as when the database
is too damaged to copy, --force restores anyway and moves the old database aside as nifty.db.replaced-<time>.
A backup made by a newer version won't restore, so update first. On a new computer, install Nifty
and stop it. Copy the backup folder to /var/lib/nifty-backups, give it to the nifty user with
sudo chown -R nifty:nifty /var/lib/nifty-backups, and then restore.
Use another folder
Choose Change… in Settings → Backups and type a full path, or set NIFTY_BACKUP_DIR in /etc/nifty.env. The
service can only write to its own folders, so let it write to the new folder too.
sudo systemctl edit nifty
[Service]
ReadWritePaths=/srv/nifty-backups
Then run sudo systemctl restart nifty. The folder must be outside /var/lib/nifty and belong to the nifty user.
Copy them to another computer
Each backup is a folder with the database and a manifest. Uploaded files are kept once, in files/, for every
backup. Copy the whole folder.
sudo rsync -a /var/lib/nifty-backups/ backup-host:/backups/nifty/
Backups aren't encrypted. Encrypt them with a tool you trust before they leave the computer. See Encrypt your data.
Keep the secret key apart
secret.key, or NIFTY_SECRET_KEY if you set it, unlocks the AI providers' API keys, and it isn't in backups. Keep
it somewhere safe, such as a password manager. Without it, a restored Nifty works, but you need to enter those API
keys again in Settings → Providers and models.
Older copies
Before backups existed, Nifty copied the database to /var/lib/nifty/nifty.db.v<N>-<time>.bak before each update.
Rolling back still finds these copies. You can delete them once you're happy.