Many people back up website files but forget the database — yet the database is where orders, users and content live. This script makes MySQL/MariaDB and PostgreSQL dumps on schedule: each database in a separate compressed file with a date, old dumps are deleted automatically, and if an error occurs you get an alert in Telegram.
The dump does not lock tables (--single-transaction), and a dump error is not masked by compression: the script honestly fails, deletes the broken file and sends an alert. The database list can be set manually or left empty — then all server databases will be saved, except system ones.
WHAT´S INSIDE THE ARCHIVE
• db-backup.sh — MySQL/PostgreSQL dumps, rotation, Telegram alerts
• .env.example — settings: connection, database list, folder, retention
• db-backup.service + db-backup.timer — daily run via systemd
• README.md — full guide: installation, permissions, schedule, restore
• Db-backup-guide.pdf — the same guide, typeset for printing (3 pages)
GUIDE STEPS
1. Settings in .env: database type, connection, dumps folder.
2. First manual run — dumps appeared, log is clean.
3. Schedule: systemd timer at 03:30 or a cron line.
4. Test restore on a separate database — the backup is verified.
WHAT YOU NEED
A server with MySQL/MariaDB or PostgreSQL and client utilities (mysqldump / pg_dump). 15 minutes to set up.
IMPORTANT
This is a script and guide for self-setup — not turnkey setup. If you need backups of your infrastructure done for you, that is a separate service.
SIMILAR PRODUCTS
• Server backups with restic:
https://e-market.su/item/6410486
• VPS Starter Kit — setup and protection of a server:
https://e-market.su/item/6397857
• VPS monitoring: Uptime Kuma + alerts:
https://e-market.su/item/6410250
• Auto-deploy a website from Git via webhook:
https://e-market.su/item/6423346
• Your own Git on a VPS: Gitea in Docker:
https://e-market.su/item/6422908