CMS backup and restoring

De Cacauet Wiki
Salta a la navegació Salta a la cerca

To backup and restore a CMS we have to follow the following procedure:

  1. Export database and filesystem of the original CMS.
  2. Import files and database in the new system.
  3. Adjust the config files of the CMS to make it work.

Export your original CMS

  1. Backup files in the source CMS (with tar, zip, etc.).
    Our suggestion is to use the command:
    $ tar cvfz cmsfoldername.tar.gz cmsfoldername
    (obviously changing cmsfoldername for your CMS folder name).
  2. Export database with mysqldump (in a *.sql file). We can use:
    • Command mysqldump. With:
      $ mysqldump -u enric -p cmsdbname > cmsdb.sql
      We will create the file cmsdb.sql with all CMS DB data. Obsioulsy you have to change "enric" for your user name.
    • phpmyadmin: too easy to give explanations for that.

That should result in having 2 files, (1) *.tar.gz and (2) *.sql.

Importing in the new system

We need 2 files: the tarball and the sql for database.

  1. Copy the files (*.sql and *.tar.gz) to your target system.
  2. Extract files in the target system.
    • Using the tar command is (you need SSH access to your system)
      $ tar xvfz cmsfoldername.tar.gz
    • If your system doesn't have SSH you can uncompress the files in your local machine and upload it using FTP.
  3. Change the folder name if you need it.
    $ mv cmsfoldername newfoldername
  4. Create the database in the target system.
    • Using mysqladmin command:
      $ mysqladmin -u enric -p create enric_newdb
      (Obviously changing enric for your username).
    • Using mysql command:
      $ mysql -u enric -p
    mysql> create database enric_newdb;
    • Using phpmyadmin
  5. Import the SQL file in the new database.
    • Using mysql command:
      $ mysql -u enric -p enric_newdb < cmsdb.sql
    • Using phpmyadmin

Adjusting config files of the new CMS

Each CMS needs to change different things. You have to look for the config file, depending on your CMS, for example:

  • Wordpress: wp-config.php
  • Mediawiki: LocalSettings.php
  • Joomla!: configuration.php

You have to review this settings to make the CMS work again:

  • DB name
  • DB user
  • DB password
  • root folder of the installation


To know more you can read that articles for database creation, export and import:

You can use several commands to synchronize your data in a remote server with your local filesystem:

  • rsync is the most common used, but you need SSH access to your site.
  • Some hostings just provide FTP service, so you can read this article for other ways to syncronize over FTP. Particularly you can use this ones:
    • mirror
    • wget: can work over FTP as well as HTTP
    • sitecopy
    • lftp (seems more complex needing a script)