Commit Graph

110 Commits

Author SHA1 Message Date
shuki
a162536585 Rename product from gniza to gniza4cp across entire codebase
- CLI binary: bin/gniza -> bin/gniza4cp
- Install path: /usr/local/gniza4cp/
- Config path: /etc/gniza4cp/
- Log path: /var/log/gniza4cp/
- WHM plugin: gniza4cp-whm/
- cPanel plugin: cpanel/gniza4cp/
- AdminBin: Gniza4cp::Restore
- Perl modules: Gniza4cpWHM::*, Gniza4cpCPanel::*
- DaisyUI theme: gniza4cp
- All internal references, branding, paths updated
- Git remote updated to gniza4cp repo
2026-03-05 21:03:30 +02:00
shuki
c20c019048 Add cPanel user activity logs page and WHM user log visibility
- Add per-user activity logging to AdminBin: every RESTORE_* action
  writes to /var/log/gniza/cpanel-<user>.log with action details and
  gniza command output
- New logs.live.cgi CGI with paginated activity list and detail view
- WHM logs.cgi now shows cpanel-*.log files with Owner column and
  structured activity entry viewer with expandable command output
- Add Logs nav item to cPanel plugin, update install.sh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 19:37:08 +02:00
shuki
a5ab2c788a Remove legacy gniza init CLI command
The WHM setup wizard handles all configuration (SSH, S3, GDrive),
making the interactive CLI init wizard redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 19:00:26 +02:00
shuki
89ca3187df Hide cron wrapper logs from logs listing
Only show per-run gniza-*.log files in the logs page. Cron wrapper
logs (cron-*.log) are redundant with the structured per-run logs
and just accumulate noise. They remain accessible via direct URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 18:09:17 +02:00
shuki
6be3e8fabf Show System Backup type in logs page
Add [TYPE:SYSBACKUP] marker to sysbackup log output. The logs page
detects this in the first 5 lines and displays "System" badge instead
of "Backup".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 18:06:54 +02:00
shuki
42ee83f433 Add SVG icons to dashboard stat cards
Each of the 6 stat cards now has a contextual SVG icon in the top-right
corner: users, shield-check, upload, server, clock, and file-text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 18:02:13 +02:00
shuki
0fb640d585 Use d/m/Y H:i:s date format for all user-facing timestamps
Update log lines, email notifications, generated config comments,
and WHM logs page. Structural dates (filenames, snapshot dirs,
.complete markers) are unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 07:35:49 +02:00
shuki
af55437bed Move hamburger menu to right side of navbar
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 06:45:43 +02:00
shuki
43fdf116cc Make navbar responsive with hamburger dropdown on small screens
Desktop (lg+) shows horizontal menu links. Smaller screens show
a dropdown hamburger button with the same navigation items.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 06:44:14 +02:00
shuki
325020338d Replace stat components with card-based layout for stats grid
DaisyUI stat components have internal styles that conflict when used
as standalone grid items, causing vertical overlap. Switch to plain
card components with manual typography classes instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 05:30:21 +02:00
shuki
46edee9dc2 Fix stats cards overlap and make grid responsive
Remove stat-figure emoji icons that caused content overflow and
switch from fixed grid-cols-3 to responsive grid-cols-2 sm:grid-cols-3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 05:26:54 +02:00
shuki
7404e88cd9 Add dashboard stats cards with cached remote data
Add 6 stat cards to the WHM dashboard showing cPanel accounts, backed up
accounts, total snapshots, remotes, schedules, and last backup status.
Remote-dependent stats are collected via `gniza stats` CLI command and
cached in stats.json, with a manual Refresh button on the dashboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 05:23:40 +02:00
shuki
3a342f091e Add disk usage and schedule columns to WHM remotes list
Enhance the remotes table with AJAX-loaded disk usage info (SSH via df,
S3/GDrive via rclone about) and server-side schedule assignment counts
with tooltip showing schedule names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 05:08:27 +02:00
shuki
237a2b7a1f Update WHM logo SVG with latest version
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:42:36 +02:00
shuki
5b2319ae6e Convert top tabs to DaisyUI navbar with menu links
Replace tabs-box with navbar component: logo+text in navbar-start,
menu links in navbar-end. Remove all inline styles, use only
Tailwind/DaisyUI classes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:36:04 +02:00
shuki
fceb9b8b88 Increase nav icon size to 48px
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:32:13 +02:00
shuki
440d741fdb Match logo text size to icon height (32px)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:21:15 +02:00
shuki
a81702f344 Increase nav logo text size from 1.4rem to 2rem
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:20:24 +02:00
shuki
ffd4792aa0 Update WHM logo: new icon + "GNIZA Backup" text in nav
Replace old logo SVG with gniza.svg and render the icon alongside
"GNIZA Backup" text where "Backup" uses the icon's orange (#f47216).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:19:46 +02:00
shuki
7b2a9ad601 Move logo inline with nav tabs instead of above them
Place the SVG icon next to the tab bar in a flex row instead of
rendering it as a separate centered block above the navigation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 04:15:58 +02:00
shuki
7f84778351 Disable Terminate First toggle in Selective restore mode
Uncheck and disable the toggle when switching to Selective so
the value cannot carry through to the confirmation step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:52:43 +02:00
shuki
1e6097eb9e Fix restore spinner not hiding due to !important CSS override
Use hidden class toggle instead of inline style.display, since
Tailwind CSS is built with the important flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:50:05 +02:00
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