♻️
Hosting

Restoring a website from backup: files and database step by step

15.11.2026
← All articles

Even when backups are routine, many people restore from one for the first time in the middle of an outage. That is exactly when it's easiest to rush and make mistakes: picking the wrong archive, overwriting a working database, or ending up with a restored site that can't connect to the database. This guide covers a safe order for restoring from a file archive and a database dump. The examples use WordPress, but the process is nearly identical for other PHP sites.

Before you start: what, and from which date

First decide what actually broke. If one plugin failed after an update, replace just that plugin. If only files were damaged, restore only files. A full restore is needed when both are damaged or the cause is unknown. Then choose the latest copy made before the problem. After a hack, malicious files often appear days or weeks before anyone notices, so yesterday's copy may not be clean. Remember that rolling back loses orders, comments and sign-ups made after that copy.

Step 1: save the current state

Even a broken site may hold new orders or messages that aren't in the backup, and a snapshot gives you a way back if the restore goes wrong:

cd ~/www
tar -czf ~/broken-files-$(date +%F).tar.gz example.uz
mysqldump --single-transaction baza_nomi | gzip > ~/broken-db-$(date +%F).sql.gz

This assumes ~/.my.cnf holds the database credentials; otherwise use mysqldump -u db_user -p.

Step 2: restore the files

Don't extract the archive over the live folder, or files an attacker added will stay in place. Extract to a separate folder, check it, then swap:

mkdir -p ~/restore
tar -xzf ~/backups/files-2026-11-01.tar.gz -C ~/restore
ls ~/restore/example.uz
mv ~/www/example.uz ~/www/example.uz.broken
mv ~/restore/example.uz ~/www/example.uz

The two mv commands are instant, so downtime is minimal. Keep example.uz.broken until you're sure the site is stable. Without SSH, do the same in the ISPmanager file manager.

Step 3: restore the database

By default mysqldump adds DROP TABLE IF EXISTS for each table, so importing into the existing database replaces those tables:

gunzip < ~/backups/db-2026-11-01.sql.gz | mysql baza_nomi

Tables created later and absent from the dump will remain. For a clean restore, create a new empty database, import into it and update the name in wp-config.php. phpMyAdmin's Import works for small databases, but file size and time limits make SSH more reliable for large dumps. If the backup came from a plugin such as UpdraftPlus, install a clean WordPress, add the plugin and restore through its interface.

Step 4: post-restore checks

The most common issue is a database connection error caused by credentials in wp-config.php that no longer match. Check the settings and site URLs:

grep -E "DB_(NAME|USER|HOST)|table_prefix" ~/www/example.uz/wp-config.php
mysql baza_nomi -e "SELECT option_name, option_value FROM wp_options
  WHERE option_name IN ('siteurl','home');"

Adjust wp_ if your prefix differs; siteurl and home must match the current address including https. Reset permissions, then clear the cache and test the home page, inner pages, forms and checkout:

find ~/www/example.uz -type d -exec chmod 755 {} +
find ~/www/example.uz -type f -exec chmod 644 {} +

Example: a travel agency in Fergana

A failed plugin update turned a Fergana travel agency's example.uz site into a white screen, and manual edits made it worse. The current state was archived, yesterday's files were extracted to a separate folder and swapped in. The database was untouched, so two bookings made the previous evening survived; a full rollback would have lost them.

Restoring after a hack

Immediately change hosting panel, FTP, database and WordPress admin passwords, update all plugins and themes and remove unused ones. sayt.uz customers can get help with panel passwords and restores through the cabinet or technical support.

Related articles

🤖 Telegram bot "Conflict: terminated by other getUpdates" error: cause and fix 🔁 Migrating a WordPress Site: Replacing URLs Without Breaking Serialized Data 📊 Grafana and Prometheus: server monitoring basics 📬 Migrating Mailboxes with imapsync Without Losing a Single Email
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓