DocumentationChapter 10 of 14
10Backups
Back up these things every day, and keep copies on another computer:
- The database. It holds all records. With SQLite, it is the file
App_Data/maintdock.db. - The
App_Datafolder. It holds the settings from the setup wizard (the database connection), the uploaded files and photos, the company logo, and the security keys. Without the keys, users must sign in again, and the SMTP password must be entered again. appsettings.json, only if you changed it by hand.
SQL Server
BACKUP DATABASE MaintDock TO DISK = 'C:\Backups\MaintDock.bak' WITH INIT;The folder (here C:\Backups) must exist, and the SQL Server service must be allowed to write to it. You can plan this as a daily job with a SQL Server Agent job or a maintenance plan. SQL Server Express has no Agent, so use Windows Task Scheduler with sqlcmd.
PostgreSQL
pg_dump -h localhost -U maintdock -F c -f maintdock.dump maintdockTo restore it into an empty database: pg_restore -h localhost -U maintdock -d maintdock maintdock.dump.
SQLite
Do not copy the database file while MaintDock runs. SQLite keeps the newest changes in the file maintdock.db-wal for a while, so a copy can miss them or be damaged. Do one of these:
- Stop MaintDock, copy the whole
App_Datafolder, and start MaintDock again. The copy then has the database, the files, and the keys. - Or make a safe copy while MaintDock runs, with the
sqlite3tool. Download it from sqlite.org/download.html (Windows: the "sqlite-tools" file), or install it on Ubuntu withsudo apt-get install sqlite3. Then run this in the app folder:Terminalsqlite3 App_Data/maintdock.db ".backup 'maintdock-backup.db'"
Docker
# The database
docker compose exec -T db pg_dump -U maintdock -F c maintdock > maintdock.dump
# The App_Data folder (files, keys, and the settings file)
docker compose cp app:/app/App_Data ./app-data-backupWith SQLite in Docker, stop the container first, so the copy of the database is complete:
docker stop maintdock
docker cp maintdock:/app/App_Data ./app-data-backup
docker start maintdockRestore
- Stop MaintDock.
- Restore the database with the tools of SQL Server or PostgreSQL. With SQLite, put the backup file in place as
App_Data/maintdock.db, and deletemaintdock.db-walandmaintdock.db-shmnext to it if they are there. - Put back the
App_Datafolder (andappsettings.json, if you changed it). - Start MaintDock.
Test a restore now and then on another computer, so you know that your backups work.