Database backup scriptDevelopment & Customization

A Bash or Python script that backs up your MySQL or PostgreSQL database and keeps only the copies you choose

Usually ready in 15 minutesRevisions includedQuality check
Packages
Payment protectionDetails
  • Revisions within the package are free.
  • If you do not respond within 3 days of delivery, the work is accepted automatically.

The money is reserved when you pay and released only once you accept the work.

A Bash or Python script that backs up your MySQL or PostgreSQL database and keeps only the copies you choose

Example result

Example for the Standard package

Merging the monthly sales files of 9 shops into one Excel report

How it is run

python merge_sales.py --month 2026-10
2026-11-02 09:14:03 INFO  Folder: sales/2026-10, 9 files found
2026-11-02 09:14:03 INFO  shop-01.csv: 1,284 rows
2026-11-02 09:14:04 INFO  shop-02.xlsx: 967 rows
2026-11-02 09:14:04 WARN  shop-07.csv: 3 rows without a price skipped (lines 88, 412, 913)
2026-11-02 09:14:05 INFO  Done: 10,412 rows -> report-2026-10.xlsx (sheets "Sales" and "Totals")

Settings, not code

The column names of each shop live in settings.ini, so a new shop or a renamed column is a line there:

[columns]
date = Date, Sale date, Day
product = Product, Item, Name
quantity = Qty, Quantity, Pcs
price = Price, Unit price

A part of the code

def read_shop_file(path: Path, columns: dict[str, list[str]]) -> pd.DataFrame:
    """Reads one shop's file and gives it the report's column names."""
    table = pd.read_excel(path) if path.suffix == ".xlsx" else pd.read_csv(path, encoding="utf-8-sig")
    renamed = {}
    for name, variants in columns.items():
        found = next((c for c in table.columns if c.strip() in variants), None)
        if found is None:
            raise ReportError(f"{path.name}: no column for '{name}' (looked for {', '.join(variants)})")
        renamed[found] = name
    table = table.rename(columns=renamed)[list(columns)]
    table["shop"] = path.stem
    return table

Files: a ZIP archive with merge_sales.py (310 lines), settings.ini, requirements.txt and a README with installing Python, running the script and what each message in the log means. The client runs it on their own computer.

Client: a small chain of 9 stationery shops; each shop sends its sales for the month as a CSV or Excel file, with slightly different column names. Task: one script that reads every file in a folder, brings the columns to one shape, and writes a single Excel report with all sales and a sheet of totals by shop.

The client and all details are made up.

About this service

A database without regular copies is one bad update or full disk away from losing orders, posts or customer records. This script, in Bash or Python as suits your server, makes a full dump of your MySQL, MariaDB or PostgreSQL database with the tools that come with it (mysqldump or pg_dump), compresses it, names it with the date and keeps only the copies your rules say, for example 7 daily, 4 weekly and 6 monthly; older ones are removed only by those rules. The database password goes into the standard option file you fill in on your server (.my.cnf or .pgpass), never into the code. You install and run it on your own server; we never log in to it. Try it on a test copy first, and restore one backup into a test database to make sure it works.

What is included

  • What you getA ZIP archive with the script, a README with step-by-step instructions and, from Standard, a settings file with databases, folders and how many copies to keep; the code is also shown on the order page.
  • Standard toolsmysqldump or pg_dump, nothing exotic to install
  • Rotation by your rulesOld copies removed only as you set
  • Password out of the codeIn .my.cnf or .pgpass on your server
  • Failures noticedFrom Standard, a failed or empty dump is logged and not counted as a copy
  • Readable codeWith comments, easy to add a database later

How it works

  1. 1
    TaskYou describe the server, the databases and how many copies to keep
  2. 2
    CodeWe write the script and the guide to installing it
  3. 3
    Try itYou run it on a test copy and restore one backup into a test database
  4. 4
    ChangesYou ask for changes within your package and send any error message

What we need from you

The database (MySQL, MariaDB or PostgreSQL) and its version, the server's system (for example Ubuntu 22.04) and whether you can install packages there, how big the database is, where the copies should be stored and how much space there is. Your rotation rules: how many daily, weekly and monthly copies to keep. For Premium, the second place for copies and the address for failure emails. Never send passwords or server access.

We will ask you:

  • Which database, and how big is it?
  • What server is it on?
  • How many copies to keep?
  • Where should copies go?
  • Bash or Python?

Compare packages

PackagesBasicOne database$16StandardBackup with settings$33PremiumBackup tool$67
Deadline1 day2 days3 days
Revisions123
Codeup to 150 linesup to 400 linesup to 1,000 lines
Files of code1up to 3up to 8
Settings fileNoYesYes
Clear error messages and a logNoYesYes
Run options and a guide to running it on a scheduleNoNoYes
Guide to installing and running it (README)YesYesYes
LanguageBash or PythonBash or PythonBash or Python
Order BasicOrder StandardOrder Premium

Payment protection

You pay when you order, but the money is released only for accepted work.

  • Fixed priceThe package price does not change after you pay.
  • The money is reservedWhen you pay, the amount is only reserved. It is released to the service once you accept the work.
  • Checked before deliveryEvery result goes through a quality check before it reaches you, and you see it on the order page before accepting it.
  • Free revisionsAsk for changes within your brief as many times as the package allows.
  • Acceptance after 3 daysIf within 3 days of delivery you neither accept the work nor ask for changes, it is accepted automatically. If you write in the order chat after delivery, the order waits; once we answer, we may start the 3 days again and will say so in the chat.
  • Redo or a full refundIf the result does not match your brief and the revisions did not fix it, or the work takes more than twice its deadline, write in the order chat: we will redo the work or refund the payment in full.
How it works →

Questions and answers

Will it delete old backups?

Only by the rules you give, such as keeping 7 daily and 4 weekly copies, and only in the backup folder it writes to. Until you set the rules, it keeps everything.

Can I keep the copies off the server?

Premium copies each backup to a second disk or to storage you already have, using its own command-line tool and your own keys, which you put into its settings yourself.

Does it lock the site while it runs?

For InnoDB tables in MySQL and for PostgreSQL the dump is taken without stopping the site. Very large databases can still slow it down, so run it at a quiet hour.

Will you set it up on my server?

No. We never log in to your server. The README shows every step, from copying the script to adding it to cron (Premium).

Did not find your answer?

Packages