Backup System
Understand backup paths, metadata, retention, cleanup, and restore-safe source handling.
The backup system supports the non-destructive promise of the plugin.
Backup storage
Backups are stored in a plugin-managed backup directory under uploads. The backup path is recorded in _vacimg_backup_path.
Creation rules
The WebP generator ensures a backup before derivative generation when backups are enabled. For WebP source optimization, the backup is essential because the source file can be replaced with a smaller WebP candidate.
Cleanup
Backup cleanup runs on the vacimg_cleanup_backups cron hook. The last cleanup time is stored in vacimg_last_backup_cleanup. Retention of 0 means keep backups indefinitely.
Restore
Restore uses the saved backup path, validates source context, restores the source file, removes derivative files where safe, and clears related metadata.
Backup verification and retention
Before Vacuum reuses a backup, it verifies the stored file. When a source changes, the earlier recovery copy is retained and a new backup is created for the new source. Restore accepts only paths inside the plugin-owned backup directory and keeps the backup after restoring. Attachment deletion removes plugin-owned derivatives without deleting backup files.