Backups, migration and staging sites
Back up and restore a site, move it to a new host or address without breaking stored data, and use staging safely, with a real backup and replace test.
In this lesson you will
- Make and test a complete backup
- Move a site to a new host
- Avoid the serialized-
data trap - Use a staging site
About 18 minutes
Moving house without breaking anything
Elif has built a client’s site on her laptop. Now it has to move to the client’s hosting, with a new address. After the move the home page loads, but half the images are missing and the menus are gone. The reason, which hides in a feature of how WordPress stores settings, is one of the most common migration traps. This lesson covers backups, restores, moving a site and testing changes on a staging copy first.
What a complete backup contains
| Part | Holds |
|---|---|
| Database | Posts, pages, settings, users, comments |
| Files | Themes, plugins, uploads, configuration |
You need both. Keep copies in more than one place, one of them away from the server. Plan how long to keep them, and encrypt copies that hold customer data. Remember the golden rule: a backup is real only after you have restored it somewhere.
Backup and restore, rehearsed for real
A test saved three posts into a backup file, deleted them to imitate an accident and restored them from the file. Then it ran the two ways of changing a web address inside stored data. The output is real:
backup file size: 1786 bytes for 3 posts
after the accident, posts found: 0
restored: 3 | titles: Zz Backup A, Zz Backup B, Zz Backup C
naive replace is still valid serialized data: NO (broken)
safe replace valid: yes -> a:2:{s:3:"url";s:23:"http://newsite.org/shop";s:5:"title";s:3:"Old";}
cleaned: yes
The restore brought back all three posts with new internal numbers, which is normal. The second half shows the migration trap. WordPress stores some settings in a format that records the length of each text. A plain find-
Moving a site, step by step
- Make a full backup of the old site (database and files).
- Prepare the new host: matching or newer PHP, a new empty database.
- Copy files and import the database.
- Update the configuration file with the new database details.
- Replace the old address with the new one using a tool that handles stored data safely.
- Save Settings, Permalinks to refresh address rules.
- Check pages, menus, images, forms, logins and search.
- Lower the DNS time-to-live beforehand, then point the domain to the new host.
- Keep the old site until the new one is confirmed, and watch for errors.
Staging sites
A staging site is a private copy used for trying updates, redesigns and new plugins. Many hosts create one with a click. Test there, write down exactly what you changed, then repeat the steps on the live site, or use the host’s push tool if it is reliable. Take care with live data: a staging copy of a shop should not send real emails or take real payments, and it should be hidden from search.
Common problems
- Images missing: the old address is still stored; use a safe replace.
- Too many redirects: a mismatch between the stored address and HTTPS settings.
- Database connection error: wrong details in the configuration file.
- Only the home page works: refresh permalinks.
- Emails fail: mail settings on the new host.
Practice
Make a full backup of a practice site. Restore it into a second location (a local tool or a hosting staging area), change the address safely and check that menus and images work. Time yourself, and write the steps in your own words as a recovery guide.
A recovery guide of ten clear lines is worth more than a perfect backup nobody knows how to use. Keep a copy of the guide outside the site, because you may need it when the site is down.
Running a raw find-
A pre-move checklist
| Check | Why |
|---|---|
| Backup tested | You can go back |
| PHP and database versions compared | Avoids surprises |
| Email plan decided | Mail may stop on the move |
| Redirects noted | Old addresses keep working |
| Search visibility checked | Do not hide the new site |
After the move, keep the old copy for a week or two. Monitor errors, forms and orders, and check Search Console for crawl problems. If anything is wrong you can point back to the old site while you fix it. A calm, written plan is what separates a smooth migration from a stressful weekend.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What does a complete backup include?
- Only the logo
- Only comments
- Only the theme
- Database and files
You need both.
Why did the naive replace fail?
- The stored text length no longer matched
- The site was offline
- The password was wrong
- The theme was old
Serialized data records lengths.
What is a staging site?
- A spam folder
- A backup of images
- A private copy for testing changes
- A kind of theme
Test there, then repeat on live.
When is a backup real?
- When it is large
- When it is old
- When it is named
- After you have restored it
Restore tests prove it.
What should you do after moving a site?
- Delete the old host immediately
- Save Permalinks and check pages, menus and forms
- Remove all plugins
- Disable backups
Keep the old site until confirmed.
Summary
- Backups need database and files, stored in two places.
- Test a restore before you need it.
- Never raw-replace addresses in a database.
- Try changes on staging first.
Questions
How often should I back up?
Match it to how often content changes: daily for busy sites, weekly for simple ones.
Can I migrate with a plugin?
Yes. Several well-known migration and backup plugins exist. Check reviews and current terms.
Why do IDs change after a restore?
Because new rows get new numbers. Good restore tools keep the original numbers; a simple import may not.
