Linux Labs

Web stack / Stage 8 of 9

A dump and a verified restore

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 7 · lab · 25 minmedium

Restore a database from a dump

After a release, an order disappeared from the shop database and some amounts changed. Bring up a copy of the database as it was before the failure, next to the damaged one, without touching it.

Situation

This machine runs the shop database of an online store in PostgreSQL. After a new version was released, an order disappeared from it and some orders got different amounts.

Every night the database is copied with pg_dump into /var/backups/shop. The team wants a copy of the database as it was before the failure, next to it, as a separate shop_restore database, to bring the data back from. shop itself stays untouched for now: the team uses it to work out what the release did. A colleague has already started restoring a copy into shop_restore, but did not finish and did not write down how far they got.

The release log is /var/log/shop/deploy.log. Run administrative commands with sudo; sudo -u postgres psql connects you as the PostgreSQL superuser. There is no internet on the machine.

Task

  1. shop_restore holds the orders and settings from the last copy taken before the failure.
  2. The tables in shop_restore are built as in that copy: columns, keys, constraints.
  3. A new order in shop_restore would get the same number it would have got at the time of the copy.
  4. The shop_restore database and everything in it belong to the shop role, as in shop.
  5. The shop database and the copy files in /var/backups/shop stay as they are.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 5
  • shop_restore holds the orders and settings from the last copy taken before the failure — not done yet
  • The tables in shop_restore are built as in that copy — columns, keys, constraints — not done yet
  • A new order in shop_restore would get the same number as at the time of the copy — not done yet
  • The shop_restore database and everything in it belong to the shop role — not done yet
  • The shop database and the copy files in /var/backups/shop are unchanged — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 5
  • shop_restore holds the orders and settings from the last copy taken before the failure — not done yet
  • The tables in shop_restore are built as in that copy — columns, keys, constraints — not done yet
  • A new order in shop_restore would get the same number as at the time of the copy — not done yet
  • The shop_restore database and everything in it belong to the shop role — not done yet
  • The shop database and the copy files in /var/backups/shop are unchanged — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 5
  • shop_restore holds the orders and settings from the last copy taken before the failure — not done yet
  • The tables in shop_restore are built as in that copy — columns, keys, constraints — not done yet
  • A new order in shop_restore would get the same number as at the time of the copy — not done yet
  • The shop_restore database and everything in it belong to the shop role — not done yet
  • The shop database and the copy files in /var/backups/shop are unchanged — not done yet
Loading…