Workspace Admin Scripts & Commands
Clean Database
./scripts/clean-db.sh
Cleans the database by removing all data while preserving the database schema and structure.
Caution
Use with caution as this will delete all existing data.
Clean build artefacts and dependencies
scripts/clean-workspace.sh
Removes all build artefacts, node_modules directory, and other generated files to ensure a clean state. This is useful when you need to perform a fresh installation or resolve dependency issues. The command will delete:
node_modules/directory.next/build directorydist/directoryout/directory.turbo/directorypnpm-lock.yamldata/*.json(development JSON backup files)public/documentationdocumentation/.docusaurus,.cache,.cache-*,build,node_modules,pnpm-lock.yaml.genkit/directory*.tsbuildinfofiles- pnpm store cache (via
pnpm store prune) - Docker build cache and system prune (images, networks, volumes)
Clean Docker Compose and Docker environment
scripts/clean-docker.sh
Perform a complete Docker cleanup, which is useful for:
- Freeing up disk space
- Removing old/unused Docker artefacts
- Cleaning up after development or testing sessions
- Maintaining a clean Docker environment
Update the packages to the latest version
You can update packages manually using:
ncu --upgrade
pnpm update
Or use the automated script (prefer source so nvm applies to your current shell; for CI or non-interactive runs use CI=1 or UPGRADE_ALLOW_EXEC=1):
source ./scripts/upgrade-dependencies.sh
The upgrade-dependencies.sh script automates the entire dependency upgrade process. It is project-agnostic: the package manager, the workspace packages, and each package's verify command are auto-detected (so the root and documentation/ packages are both upgraded, with no hardcoded paths). It:
- Sources tool setup via
upgrade-tools.sh(nvm / Node LTS, globalpnpm,npm-check-updates,doctoc) - Performs build-safe upgrades with
npm-check-updatesdoctor mode for each package: it keeps upgrades that pass the package'stypecheck/lintand reverts the ones that break the build (with an embedded ESLint peer gate soeslintand React plugin bumps stay compatible) - Updates the workspace pnpm lockfile and installs dependencies
- Updates the browserslist database
- Checks for vulnerabilities (
pnpm audit) and applies non-breaking fixes (pnpm audit --fix) - Prioritises security: if a vulnerable direct dependency can only be fixed by a build-breaking upgrade, the safe version is force-applied and the build errors are reported so the code can be updated for compatibility
- Prints a summary (upgraded vs. build-breaking packages skipped, vulnerabilities fixed/remaining, and a manifest snapshot path for manual rollback)
This script provides a complete workflow for keeping dependencies up to date and secure.
Check for unused packages
pnpm depcheck
Update version information
./scripts/update-version.sh
This script automatically updates version information across multiple files to keep them synchronized. It:
- Extracts the version from
package.json - Updates the
.envfile with theVERSIONvariable (creates it if it doesn't exist) - Updates the
Dockerfilewith theVERSIONvariable (if it exists) - Updates the
documentation/package.jsonversion field (if it exists) - Only updates if the version has changed
- Provides feedback on each operation
Pre-checks script
./scripts/pre-checks.sh
This script runs pre-checks before starting the development server, building, or starting the production server. It:
- Ensures the
.duplistatus.keyfile exists (viaensure-key-file.sh) - Updates the version information (via
update-version.sh)
This script is automatically called by pnpm dev, pnpm build, and pnpm start-local.
Ensure key file exists
./scripts/ensure-key-file.sh
This script ensures the .duplistatus.key file exists in the data directory. It:
- Creates the
datadirectory if it doesn't exist - Generates a new 32-byte random key file if missing
- Sets file permissions to 0400 (read-only for owner)
- Fixes permissions if they are incorrect
The key file is used for cryptographic operations in the application.
Admin account recovery
./admin-recovery <username> <new-password>
This script allows recovery of admin accounts if locked out or password forgotten. It:
- Resets the password for the specified user
- Unlocks the account if it was locked
- Resets failed login attempts counter
- Clears the "must change password" flag
- Validates password meets security requirements
- Logs the action to the audit log
Example:
./admin-recovery admin NewPassword123
Caution
This script directly modifies the database. Use only when necessary for account recovery.
Copy images
./scripts/copy-images.sh
Copies image files from documentation/static/img to their appropriate locations in the application:
- Copies
favicon.icotosrc/app/ - Copies
duplistatus_logo.pngtopublic/images/ - Copies
duplistatus_banner.pngtopublic/images/
Useful for keeping application images synchronized with documentation images.
Compare versions between development and Docker
./scripts/compare-versions.sh
This script compares versions between your development environment and a running Docker container. It:
- Compares SQLite versions by major version only (e.g., 3.45.1 vs 3.51.1 are considered compatible, shown as "✅ (major)")
- Compares Node, npm, and Duplistatus versions exactly (must match exactly)
- Displays a formatted table showing all version comparisons
- Provides a summary with color-coded results (✅ for matches, ❌ for mismatches)
- Exits with code 0 if all versions match, 1 if there are mismatches
Requirements:
- Docker container named
duplistatusmust be running - The script reads version information from Docker container logs
Example output:
┌─────────────────────────┬──────────────────────────────┬──────────────────────────────┬──────────────┐
│ Component │ Development │ Docker │ Match │
├─────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────┤
│ SQLite │ 3.45.1 │ 3.51.1 │ ✅ (major) │
│ Node │ 24.12.0 │ 24.12.0 │ ✅ │
│ npm │ 10.9.2 │ 10.9.2 │ ✅ │
│ Duplistatus │ 1.2.1 │ 1.2.1 │ ✅ │
└─────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────┘
Note: SQLite versions are compared by major version only because different patch versions within the same major version are generally compatible. The script will indicate if SQLite versions match at the major level but differ in patch versions.
Viewing the configurations in the database
sqlite3 data/backups.db "SELECT key, value FROM configurations;" | awk -F'|' '
{print "\n" $1 ": ";
if(index($2,"{")>0) {print $2 |"jq -C ."; close("jq -C .")}
else {print $2;}}' | less -R
sqlite3 /var/lib/docker/volumes/duplistatus_data/_data/backups.db "SELECT key, value FROM configurations;" | awk -F'|' '
{print "\n" $1 ": ";
if(index($2,"{")>0) {print $2 |"jq -C ."; close("jq -C .")}
else {print $2;}}' | less -R
Show backup settings
./scripts/show-backup-settings.sh [database_path]
Displays the contents of the backup_settings value in the configurations table in a formatted table. Useful for debugging notification configurations. Default database path: data/backups.db.