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¶
- Automatic triggering: Supports fingerprint comparison at startup, periodic checks, plugin table events, and manual triggering.
- Rotating naming: The latest backup is named
web.latest_bak, while older backups use numeric timestamps. - Retention policy: Supports configuring
retentionDays(days to keep),maxBackups(maximum number of backups), andbackupDir(backup directory). - Settings page integration: Provides configuration items for backup directory, retention period, immediate backup, and restore guidance.
- Precise cleanup: Only cleans up backup directories matching
web.latest_bakorweb.<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.bundlesin bundle form. web.latest_bakis the backup generated after a plugin table change. If it is corrupted, roll back toweb.YYYYMMDDHHMM.
Conclusion¶
This plugin reduces the risk of losing environment configuration by automating the backup process.