These steps are for shared hosting. They use the panel, not a root shell on a server.
Backups
Most restores people need are small: one page edited wrongly, one file deleted, one table emptied by a bad update. Restoring the whole site to fix that throws away every order and comment since the backup - which is usually a bigger loss than the original mistake.
One file from an archive
tar -tzf backup.tar.gz | grep wp-config
tar -xzf backup.tar.gz -C /tmp/restore path/inside/archive/wp-config.php
Extract to /tmp first, always. Look at it, then copy it into place - extracting straight over the site is how a small restore becomes a large one.
One table from a dump
sed -n '/-- Table structure for table `wp_posts`/,/-- Table structure for table `wp_postmeta`/p' backup.sql > wp_posts.sql
mysql -u user -p dbname < wp_posts.sql
A dump is plain text in table order, so the range between one table header and the next is exactly one table.
mysql -u user -p dbname_restore < wp_posts.sql
# then
INSERT INTO dbname.wp_posts SELECT * FROM dbname_restore.wp_posts WHERE ID = 123;
Know what is in the backup before you need it
tar -tzf backup.tar.gz | head -30
grep -c "CREATE TABLE" backup.sql
Two minutes now, once, saves an hour on the day something is wrong - and the day something is wrong is not the day to find out the uploads were never included.
