A transaction groups changes so they all happen or none do, which is essential for things like moving money. pg_dump creates a backup you can restore anywhere.
BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = 1; UPDATE accounts SET balance = balance + 100 WHERE id = 2; COMMIT; -- or ROLLBACK; to undo both docker exec pg pg_dump -U postgres shop > shop-backup.sql