MaintDockDocumentation

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_Data folder. 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

SQL
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

Bash
pg_dump -h localhost -U maintdock -F c -f maintdock.dump maintdock

To 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_Data folder, 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 sqlite3 tool. Download it from sqlite.org/download.html (Windows: the "sqlite-tools" file), or install it on Ubuntu with sudo apt-get install sqlite3. Then run this in the app folder:
    Terminal
    sqlite3 App_Data/maintdock.db ".backup 'maintdock-backup.db'"

Docker

Bash
# 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-backup

With SQLite in Docker, stop the container first, so the copy of the database is complete:

Bash
docker stop maintdock
docker cp maintdock:/app/App_Data ./app-data-backup
docker start maintdock

Restore

  1. Stop MaintDock.
  2. 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 delete maintdock.db-wal and maintdock.db-shm next to it if they are there.
  3. Put back the App_Data folder (and appsettings.json, if you changed it).
  4. Start MaintDock.

Test a restore now and then on another computer, so you know that your backups work.