Backup & Restore Database
Table of Contents
Always use the UI to create a backup of the DB. As with all live databases DO NOT copy manually the database file as a means of backup. The
Download Backup tasks are the proper way to create a backup file.
Stash uses an sqlite database with
WAL mode enabled. This practically means that along with the main db file
stash.go-sqlite there can be a
-shm and a
-wal file present (more info). Even stopping Stash might leave some of these index files present so again DO NOT manually copy the database file.
Assuming you have properly created a backup file you can use it to restore your database if needed. For the location of the db file check your configuration’s
Database Path. The restore procedure uses the default
stash-go.sqlite filename, if you changed that when configuring stash adjust accordingly.
The following steps are recommended when restoring a database file.
- Create a backup of the current database (Optional)
- Stop stash
- Move or delete the
stash-go.sqlitedatabase file (along with the
.journalfiles if present)
- Copy the backup file that you want to restore to
- Make sure that you now have a
stash-go.sqlitefile and that no
.journalfiles are present.
- Start stash
You should now have stash running with a working and restored database.
If you get a database malformed message during upgrade or backup that probably means that the database is already corrupt. One way to get past that is to do a full export and check the error log. If there are not a lot of errors you can then try to do a full import and get a working db with minimal losses. As the full import is destructive proceed with caution. For cases like this it is better to visit the discord channel.