Daily Operations
Cron Schedule
Section titled “Cron Schedule”# /var/spool/cron/ancora (or /etc/cron.d/ancora)30 23 * * * ancora /home/ancora/scripturi/daily_job.shRuns every night at 23:30 as the ancora user.
daily_job.sh — Full Flow
Section titled “daily_job.sh — Full Flow”flowchart TD
START(["23:30 — cron triggers\ndaily_job.sh"])
A["1. Fetch BNR exchange rates\nwget https://bnr.ro/nbrfxrates.xml\nParse XML → call cursbnr00.jsp\nUpdates cursvalutarbnr in ALL tenant DBs"]
B["2. Generate daily reports\nPOST /ancoraerp/daily_reports.serv\nBuilds HTML sales/stock summary\nAttempts email to disponibilul@gmail.com"]
C["3. Read tenant list\nSELECT bazadate FROM public.unitati\nWHERE inactiv=false AND isbackup=false"]
D["4. For each tenant DB in list…"]
E["4a. vacuumdb --freeze --analyze\n(prevents XID wraparound,\nupdates query planner stats)"]
F["4b. pg_dump -Fc\nDump to /home/ancora/backup/\$(date +%%u)/\${dbname}.dump\n(overwrites same weekday slot from last week)"]
G["4c. auto_actdb.serv\nApply any pending SQL migration scripts\n(1493 scripts total as of mid-2025)"]
H["5. Restart PostgreSQL service\nsystemctl restart postgresql-11\n(ensures clean connection pool)"]
I["6. Send summary email\nBuilds HTML report of backup sizes,\nmigration results, errors\nSMTP: 192.168.0.105:25 (primary)\nSMTP: smtp.gmail.com:465 (fallback)"]
ERR["⚠ Both SMTP servers currently\nunreachable — emails silently fail"]
DONE(["Done — sleep until 23:30 next night"])
START --> A --> B --> C --> D
D --> E --> F --> G
G -->|next tenant| D
D -->|all tenants done| H --> I
I -->|delivery failure| ERR
I --> DONE
ERR --> DONE
7-Day Backup Rotation Detail
Section titled “7-Day Backup Rotation Detail”/home/ancora/backup/├── 1/ ← Monday│ ├── maxx.dump # ~418 MB compressed│ └── maxx_suport.dump # ~87 MB compressed├── 2/ ← Tuesday│ └── ...├── 3/ ← Wednesday│ └── ...├── 4/ ← Thursday│ └── ...├── 5/ ← Friday│ └── ...├── 6/ ← Saturday│ └── ...└── 7/ ← Sunday └── ...- Slot key:
$(date +%u)— ISO day-of-week (1=Mon, 7=Sun) - Retention: 7 rolling days (previous week’s same-day file is overwritten)
- Format:
pg_dump -Fc(custom compressed, not plain SQL) - Restore:
pg_restore -d targetdb backup/3/maxx.dump - No off-site sync detected — backups exist on the same machine
auto_actdb.serv — Schema Auto-Updater
Section titled “auto_actdb.serv — Schema Auto-Updater”Called once per tenant DB per night. Keeps every tenant DB in sync with the latest schema version deployed in actualizaredb/.
sequenceDiagram
participant SH as daily_job.sh
participant TC as Tomcat
participant SVC as DarkAutomaticActualizare
participant FS as /actualizaredb/*.sql
participant PG as Tenant PostgreSQL DB
SH->>TC: wget http://localhost:8080/ancoraerp/auto_actdb.serv?db_email=maxx&email=...
TC->>SVC: BasicServicesController dispatches
SVC->>PG: SELECT COALESCE(MAX(nr_actualizare),0) FROM setari_actualizare
PG-->>SVC: current = 1480
SVC->>FS: list files 1481.sql … 1493.sql
loop for each pending file
SVC->>PG: execute SQL from file N.sql
SVC->>PG: INSERT INTO setari_actualizare(nr_actualizare, data) VALUES(N, NOW())
end
SVC-->>SH: HTML: "Applied 13 updates successfully"
Monitoring Gap
Section titled “Monitoring Gap”There is no active monitoring stack detected:
| Component | Status |
|---|---|
| Nagios / Zabbix / Prometheus | Not installed |
| Log rotation | logrotate.conf present (standard CentOS) |
| Tomcat logs | /opt/tomcat/logs/catalina.out (unbounded) |
| Disk usage alerts | None |
| Backup verification | None (no test-restore process) |
| Email alerts | Configured but SMTP broken |
| AnyDesk | Installed — remote access for manual troubleshooting |
Application Update Mechanism
Section titled “Application Update Mechanism”Software updates arrive via the maxx user account or direct Tomcat WAR replacement:
flowchart LR
VENDOR["ancora.ro vendor"] -->|"SCP / manual upload\nor Tomcat manager"| TOMCAT["Tomcat webapps/\nancoraerp/"]
TOMCAT -->|"JARs in WEB-INF/lib/"| NEWJARS["Updated business JARs\n(ancora-mailer.jar,\naprovizionare.jar, etc.)"]
TOMCAT -->|"actualizaredb/NNNN.sql"| SQLSCRIPTS["New DB migration scripts"]
SQLSCRIPTS -->|"next auto_actdb.serv run"| ALLTENANTS["Applied to all tenant DBs\nautomatically next night"]
The cale_dark_cloud parameter (http://82.77.60.34:9999/) points to a central Ancora server — this is used for:
- License key verification
- D394 fiscal declaration processing (Romanian VAT return)
- Possibly pushing WAR/JAR updates (unconfirmed)