Wordpress: moving an existing blog to localhost Scrivi un commento!

Wordpress: moving an existing blog to localhost

wordpress.jpg Versione italiana
Sometimes you need to save locally an existing Wordpress installation, for various reasons: to have a backup for tests, to modify a theme, moving the blog to a new server, etc.

With this article, you’ll see how to create a complete and perfect backup, translating all the URLs in the database to match your new host (http://localhost/ for local copies, or http://newserver.org/ for host changes). Even images’ URLs will be fixed.

Prerequisites
An existing ftp and database backup; you can follow Tamba2’s guide to learn how to create them.

Note

The commands shown on this article are for Linux and Mac OS X only. To replace all the URLs in the database dump under Windows, you can try SCR freeware edition.

Modifying the database dump with SED
Linux and Mac OS X have got a wonderful shell command for string substitutions: sed. We’ll use it to change “http://oldurl.org” into “http://newurl.org”, and we’ll save the modified sql dump file into a new one (for backup purpouses).

With the shell, go to the directory that contains the .sql file, and type:$ sed -e 's^OLD_URL^NEW_URL^g' ORIGINAL_FILE.sql > COPY.sql

For example, I typed:

$ sed -e 's^http://techlog.netsons.org^http://localhost/wordpress^g' dump.sql > dump_local.sql

Note: don’t add a trailing slash in the URLs.

Now you can import the modified dump file (for example, with phpmyadmin).

The last step you have to do is rebuilding the Permalinks, to avoid strange behaviors (like unnatural slowdowns). On your new host, go to the dashboard, Options / Permalinks and simply press the Update Permalink Structure button.

That’s all! :D

Articoli simili:

Se questo articolo ti è stato utile, segnalalo sul tuo sito! Puoi inoltre seguire comodamente gli aggiornamenti di Techlog tramite il feed RSS; infine puoi lasciare un commento se ti serve aiuto (o anche solo per un saluto); anche qui non serve registrarsi (sono abilitati anche i commenti anonimi; l'E-Mail serve, eventualmente, per ricevere le notifiche delle nuove risposte). ;-)

3 Responses to “Wordpress: moving an existing blog to localhost”

  1. » Wordpress: spostare il blog dal server remoto al computer locale « Blog Archive « Techlog Says:

    […] it! « Risolti i problemi di Qemulator in Debian Lenny Wordpress: moving an existing blog to localhost […]

  2. matte89thebest Says:

    mmm non è proprio pertinente con il tuo articolo, ma il mio problema, e quello di centinaia di persone in rete è quello di poter eseguire il backup del proprio blog tramite plugin wordpress su server windows!
    se è chiara da tempo la soluzione per la gestione degli upload nella cartella public su server windows ARUBA, non sono ancora riuscito a trovare una soluzione chiara al problema di eseguire operazioni fondamentali come:
    backup database wordpress su aruba e windows (problema scrittura directory) e creazione della sitemap xml con google sitemap plugin!

    Se haia vuto modo di risolvere il problema del backup te ne sarei molto grato!
    PS–> per passare da windows a linux è difatti necessario eseguire il backup

  3. Andrea Romagnoli Says:

    @ matte89thebest:
    Su hosting Windows non ho mai avuto esperienza, mi spiace. :(

    Comunque, in linea di massima, io per i backup non mi affido a plugin, ma mi affido alla vecchia maniera: il backup manuale con 1) client ftp 2) phpmyadmin. Per fare il backup del database su Windows, in caso, chiedi direttamente all’assistenza di Aruba, aprendo un ticket ;)

Leave a Reply


SMS Gratis