This task asks you to generate a harmless, small SQL dump file that mimics a real backup. The dump should contain a few CREATE TABLE statements followed by INSERT statements. The result will reside under /tmp/pg_backup/postgres_dump.sql.
Steps:
Prepare the destination directory: ensure /tmp/pg_backup exists. You can create it with mkdir -p /tmp/pg_backup.
Create the dump file: /tmp/pg_backup/postgres_dump.sql and populate it with a minimal, valid PostgreSQL-compatible schema and data. Example content below or equivalent:
-- PostgreSQL sample backup
CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
balance NUMERIC(12,2) DEFAULT 0
);
INSERT INTO accounts (name, balance) VALUES
('Alice', 120.00),
('Bob', 54.25);
CREATE TABLE transactions (
t_id SERIAL PRIMARY KEY,
account_id INTEGER REFERENCES accounts(id),
amount NUMERIC(12,2) NOT NULL
);
INSERT INTO transactions (account_id, amount) VALUES
(1, 20.00),
(2, 35.50);
Validate: verify that the file exists and that the content includes at least two CREATE TABLE statements and two INSERT statements.
Optional checks: display the first few lines with head -n 20 /tmp/pg_backup/postgres_dump.sql.
Deliverables:
The file at /tmp/pg_backup/postgres_dump.sql containing the sample dump.
A short verification note (could be your terminal commands and their results) that shows the path and a snippet of the content.
Notes:
This is a safe, fictional dump for benchmarking; do not connect it to any real database.