Commit Graph

88 Commits

Author SHA1 Message Date
shuki
6ecba2ae43 Load restore account dropdown from remote backups via AJAX
The WHM restore page now populates the account dropdown dynamically
from the selected remote, making terminated/removed accounts visible
and restorable. Accounts not on the local server show "(terminated)".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:43:00 +02:00
shuki
d069c490ae Add Status column (Success/Warning/Error) to WHM logs list
Scans each log file for [ERROR] and [WARN] markers and displays
a color-coded badge in the logs table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:40:45 +02:00
shuki
a779d861a6 Fix CSRF upgrade path: remove stale file before creating directory
Old versions stored CSRF/flash as plain files at the directory path.
New code expects directories. _ensure_dir now removes conflicting
plain files left by older versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 00:14:33 +02:00
shuki
cc7e46a88f Fix CSRF token write failure and SMTP test token sync
- Add fallback write when O_EXCL _safe_write fails for CSRF tokens
  (ensures token is always persisted to disk)
- Update SMTP test JS to sync new CSRF token into main form hidden field
  (prevents stale token after SMTP test consumes the original)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 00:09:24 +02:00
shuki
1f68ea1058 Security hardening, static analysis fixes, and expanded test coverage
- Fix CRITICAL: safe config parser replacing shell source, sshpass -e,
  CSRF with /dev/urandom, symlink-safe file I/O
- Fix HIGH: input validation for timestamps/accounts, path traversal
  prevention in Runner.pm, AJAX CSRF on all endpoints
- Fix MEDIUM: umask 077, chmod 700 on config dirs, Config.pm TOCTOU lock,
  rsync exit code capture bug, RSYNC_EXTRA_OPTS character validation
- ShellCheck: fix word-splitting in notify.sh, safe rm in pkgacct.sh,
  suppress cross-file SC2034 false positives
- Perl::Critic: return undef→bare return, return (sort), unpack @_,
  explicit return on void subs, rename Config::write→save
- Remove dead code: enforce_retention_all(), rsync_dry_run()
- Add require_cmd checks for rsync/ssh/hostname/gzip at startup
- Escape $hint/$tip in CGI helper functions for defense-in-depth
- Expand tests from 17→40: validate_timestamp, validate_account_name,
  _safe_source_config (including malicious input), numeric validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 23:57:26 +02:00
shuki
b16893086d Add terminate-before-restore toggle, logo, and installer improvements
- Add "Terminate First" toggle to restore page (UI, Runner, CLI, lib)
- When enabled, removes existing cPanel account before restoring
- Add GNIZA Backup SVG logo to WHM plugin header (inline base64)
- Copy uninstall.sh to /usr/local/gniza/ during installation
- Update CLAUDE.md with new restore params and Runner options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 21:43:48 +02:00
shuki
b8858bcbc8 Remove restore strategy (merge/terminate) from all layers
Restores now always merge into existing accounts (--force). The
terminate-and-recreate option is removed from CLI, restore library,
Runner allowlist, and WHM UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:47:28 +02:00
shuki
ee2a0100f6 Remove Restore Strategy toggle from restore page
Always defaults to merge (overwrite) strategy. The terminate & re-create
option is removed from the UI to simplify the restore workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:45:43 +02:00
shuki
8dcd3aaca7 Add info tooltips to form fields across remotes, settings, and restore pages
Adds ⓘ tooltip icons with contextual help text to technical fields:
- remotes.cgi: SSH key, S3 endpoint, GDrive service account/folder ID,
  base dir, bandwidth limit, rsync options, retention count
- settings.cgi: working dir, log retention, include/exclude accounts,
  lock file, SSH timeout/retries, rsync options
- restore.cgi: restore mode, restore strategy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:28:57 +02:00
shuki
5b19d5d29e Fix empty retention count display on remotes list page
Fall back to default '30' when RETENTION_COUNT is set to empty string,
not just when the key is missing from the config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:26:29 +02:00
shuki
afff4ef091 Change remote selection from checkboxes to toggles in schedule form
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:25:50 +02:00
shuki
2a646e52f8 Fix tooltip icon wrapping and position on schedule option toggles
Widen label to w-52 with whitespace-nowrap to prevent the info icon
from wrapping to a new line. Change tooltip position from right to top.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:24:17 +02:00
shuki
51ae90e221 Add circled question mark icons for tooltip triggers on schedule options
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:22:03 +02:00
shuki
60b7c6d9cb Replace description paragraphs with tooltips on schedule option toggles
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:18:15 +02:00
shuki
ffb27d5bf7 Merge system backup and skip suspended toggles into single Options card
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:17:22 +02:00
shuki
bea3ff05cb Add exclude paths for restore and skip-suspended/schedule enhancements
- Add --exclude flag to restore account/files commands to skip specific
  paths during homedir restoration (rsync --exclude / rclone --exclude)
- Add exclude paths UI in WHM restore form (step 2 tag input + modal,
  step 3 summary, step 4 command building)
- Add rclone_from_remote_filtered() for passing extra args to rclone copy
- Add _build_exclude_args() helper in restore.sh
- Add exclude pattern to Runner.pm allowlist
- Add skip-suspended flag and schedule configuration enhancements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:10:33 +02:00
shuki
0eb480489e Add per-schedule toggle to skip suspended cPanel accounts
Adds SKIP_SUSPENDED config key and --skip-suspended CLI flag that
excludes suspended accounts (detected via /var/cpanel/suspended/)
from backups. Follows the same pattern as the existing SYSBACKUP
toggle across all layers: config, schedule loader, cron builder,
CLI flag parsing, and WHM UI (table toggle, AJAX handler, form card).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:10:18 +02:00
shuki
7393412b20 Fix button vertical alignment on restore page
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:09:30 +02:00
shuki
7083efcc05 Add background job execution for restore and live status dashboard
- Runner.pm: extract _validate()/_build_cmd_line(), add run_async() that
  forks a detached child via setsid() to run commands in background
- restore.cgi: handle_step4() builds commands array and uses run_async()
  instead of blocking synchronous execution, redirects to logs.cgi
- logs.cgi: add auto-refresh JS (10s list view, 5s file view with
  auto-scroll) that polls index.cgi?action=status while gniza is running
- index.cgi: add live status card with AJAX polling and JSON endpoint
- Cron/schedule: redirect cron output to /dev/null (gniza has own logs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:07:09 +02:00
shuki
6a2986c505 Show SSH Key Setup accordion on edit remote too
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:06:02 +02:00
shuki
c602df43f6 Convert SSH Key Setup to collapsed accordion
Uses DaisyUI collapse component so the SSH guidance is hidden
by default and expandable on click.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:04:26 +02:00
shuki
ade44dfff4 Align button rows with items-center to fix vertical misalignment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:01:02 +02:00
shuki
35eac96f25 Change all Cancel/Back buttons from btn-ghost to btn-info
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:59:18 +02:00
shuki
6511715b2b Add Sys Backup toggle column to schedules list
Adds a "Sys Backup" column with an AJAX toggle in the schedules
table. Toggling it updates SYSBACKUP in the schedule config and
reinstalls the cron entry to include/remove --sysbackup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:49:48 +02:00
shuki
543b38bd53 Add 'gniza schedule run <name>' command
Runs a schedule's backup immediately with the correct --remote and
--sysbackup flags from the schedule config. Also fixes WHM Run Now
button to include --sysbackup when enabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:46:26 +02:00
shuki
e0982fe7a1 Add --sysbackup flag to Cron.pm cron line builder
Cron.pm's install_schedule() had its own cron line builder that
didn't include --sysbackup. Now it checks SYSBACKUP=yes in the
schedule config and appends --sysbackup to the cron command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:38:46 +02:00
shuki
0da580666c Always reinstall cron when saving a schedule
Previously the cron was only updated if it was already active.
Now every save reinstalls the cron entry so changes (like enabling
--sysbackup) take effect immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:36:20 +02:00
shuki
3547b00ead Add sysbackup/sysrestore CLI commands and schedule integration
- Add lib/sysbackup.sh and lib/sysrestore.sh for system-level
  backup and restore of WHM/cPanel config, packages, and cron jobs
- Wire cmd_sysbackup and cmd_sysrestore into bin/gniza
- Add --sysbackup flag to cmd_backup: runs system backup after all
  account backups complete
- Add SYSBACKUP schedule config key so cron jobs can include
  --sysbackup automatically via build_cron_line()
- Add "Include system backup" toggle to WHM schedule form
- Revert sysbackup toggle from remotes.cgi (belongs in schedules)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:30:10 +02:00
shuki
417bb8cd39 Show system backup toggle on edit remote too
The sysbackup toggle is now available for both add and edit flows,
so users can trigger a system backup against any existing remote.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:24:37 +02:00
shuki
376d6078aa Add initial system backup toggle to remote setup form
When adding a new remote, a toggle lets the user immediately run
gniza sysbackup against the new remote. The backup forks to
background with output logged to /var/log/gniza/sysbackup-<name>.log.
Toggle is hidden on edit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:23:16 +02:00
shuki
3a74e4fd7a Add client-side table sorting to all tables
Clicking any column header sorts the table rows. Supports text and
numeric sorting with ascending/descending toggle and arrow indicators.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:48:51 +02:00
shuki
46b5644074 Sort snapshot dropdown latest first (descending)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 06:00:40 +02:00
shuki
7bb6dca83f Add pagination to logs table (25 per page)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:55:43 +02:00
shuki
4784795f4d Change log View button to btn-secondary
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:51:18 +02:00
shuki
f9326390d7 Convert all anchor buttons to button elements for consistent sizing
WHM styles override <a> tag padding, making anchor-based buttons
larger than native buttons. Using <button> elements everywhere
ensures uniform button sizing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:50:11 +02:00
shuki
0ada0cc034 Standardize all table action buttons to btn-sm and use button elements
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:48:09 +02:00
shuki
67f146609f Convert Edit from anchor to button to match Delete sizing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:47:29 +02:00
shuki
3a0379846e Reduce base font size from 2.3rem to 1.6rem for normal button sizing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:46:10 +02:00
shuki
2831d91916 Change schedule Edit button to btn-primary
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:45:12 +02:00
shuki
5d32eee62f Use btn-xs for table action buttons in remotes and schedules
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:44:57 +02:00
shuki
ef491b6c2d Increase top padding to 30px on main container
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:44:04 +02:00
shuki
afdbdd14a1 Use inline style for container padding (scoped CSS can't target itself)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:43:09 +02:00
shuki
5c9e170454 Fix main container padding using standard Tailwind class p-2.5
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:41:35 +02:00
shuki
d5c53b254e Add 10px padding to main container
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:40:19 +02:00
shuki
83942e6b12 Remove page title from WHM plugin header
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:39:20 +02:00
shuki
58748b3df8 Add 'Add New' buttons to dashboard Remotes and Schedules cards
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:38:48 +02:00
shuki
f19609423f Rename display text to GNIZA Backup Manager across all WHM pages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:37:26 +02:00
shuki
3805b87300 Use bg-white for card backgrounds across all WHM pages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:34:34 +02:00
shuki
100bad0599 Make base-100 transparent to inherit WHM background
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:33:18 +02:00
shuki
5a8470b3f5 Remove explicit background color to inherit WHM's background
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 05:32:07 +02:00