Linux Labs

Web stack / Stage 8 of 9 · step 6 of 7

Restore a database from a dump

medium ~25 min
Not running Starting usually ~20 s
Report a problem

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.

Visible only to you. Saved as you type.

All notes

Lab goals

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

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…