dsh-env-backup: DSH Environment Automatic Backup Plugin

Introduction

In DSH environment development, installing or updating plugins may modify the plugin table, causing configuration conflicts. If the environment becomes corrupted, rollback is necessary. The dsh-env-backup plugin automatically backs up the ~/.dsh/profiles/web directory when the plugin table changes, and uses rotating naming and retention policies to prevent loss of the environment.

Plugin Positioning

dsh-env-backup is an automatic backup plugin for DSH environments, maintained by ikanger. It addresses the following issue: when installing/updating plugins causes the web plugin table to change, it automatically backs up the ~/.dsh/profiles/web directory, with support for rotating naming and automatic cleanup based on retention policies.

Core Features

  1. Automatic triggering: Supports fingerprint comparison at startup, periodic checks, plugin table events, and manual triggering.
  2. Rotating naming: The latest backup is named web.latest_bak, while older backups use numeric timestamps.
  3. Retention policy: Supports configuring retentionDays (days to keep), maxBackups (maximum number of backups), and backupDir (backup directory).
  4. Settings page integration: Provides configuration items for backup directory, retention period, immediate backup, and restore guidance.
  5. Precise cleanup: Only cleans up backup directories matching web.latest_bak or web.<12-digit timestamp>.

Installation and Enabling

The installation command is as follows:

dsh plugin --profile web add github:<your-username>/dsh-env-backup

After installation, restart dsh to apply the changes.

Typical Usage

Environment Recovery

If the environment crashes:
1. Stop dsh.
2. Copy web.latest_bak (or a specific web.YYYYMMDDHHMM) from the backup directory back to profiles/web.
3. Restart dsh.

Configuring the Backup Policy

You can adjust the retention policy on the settings page. The configuration is persisted to ~/.dsh/web-backup.json.

Notes

  • The default backup directory is ~/.dsh/profiles.
  • The generated configuration file is located at ~/.dsh/web-backup.json.
  • The plugin is written into the profile’s dsh.profile.bundles in bundle form.
  • web.latest_bak is the backup generated after a plugin table change. If it is corrupted, roll back to web.YYYYMMDDHHMM.

Conclusion

This plugin reduces the risk of losing environment configuration by automating the backup process.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye