This article will help you to back up your website data and databases locally to your computer before you install a new operating system on your IONOS VPS, in order to import them again. As all data on the server is deleted when the operating system is reinstalled, it's essential to create a backup.

In this article, you will learn how to:

  • Determine required website data and configuration files for Apache and Nginx.
  • Export the MySQL database used.
  • Save the website files and the exported MySQL database locally to your computer.
  • Reinstall the Apache, Nginx, PHP, and MySQL applications after reinstalling the operating system.
  • Import the backed-up data and the database from your local computer back to the VPS.
Caution

It is recommended to migrate your existing server data to a new server (e.g., a newly ordered/created VPS) while keeping your existing server active. This way, if setup, migration, or configuration of the new server takes longer than expected, you don't have to worry about excess downtime as your existing server remains available.

You can find our latest VPS deals here: https://www.ionos.co.uk/servers/vps

You can find out more information on migrating websites to a new Linux server in the following article: Manually migrating websites to a new server (Linux)

If instead, you decide to reimage your existing server with a newer operating system, all data that exists on the VPS will be irrevocably deleted. Make sure that you have successfully completed all backup steps, including exporting the database, and downloading the files, before you start the installation of a new operating system on your existing IONOS VPS within your Cloud Panel .

Notes

  • This process requires careful planning and implementation.

  • Check which security settings and configurations need to be made after installing the new operating system. This applies to both the installed operating system and the installed applications.

  • Make sure that the functionality of your websites, applications, and scripts are carefully tested. Allow sufficient time for testing and bug fixing.

  • If necessary, inform your users about planned downtimes.

  • The backup and migration of data is your responsibility, and is not part of IONOS support.

Determine website files

Before you delete the system, you must determine the required website files.

Apache
  • Establish an SSH connection to your VPS and log in as an administrator. You can find instructions in the following article: Connecting to a Linux server via SSH
  • To search for text containing the name of your domain in all files in the /etc/apache2/sites-enabled directory and its subdirectories, replace the placeholder in the command below. Then enter the command.

    [root@localhost ~]# grep -Ril "DOMAINNAME" /etc/apache2/sites-enabled

    Example:

    [root@localhost ~]# grep -Ril "example.com" /etc/apache2/sites-enabled

    The file path for the configuration file of your website is then displayed. Example:

    /etc/apache2/sites-enabled/example.com.conf

  • Open the file with the vi editor. To do this, adapt the command below and then enter it:

    [root@localhost ~]# vi /etc/PFAD/DATEINAME.conf

    Example:

    [root@localhost ~]# vi /etc/apache2/sites-enabled/example.com.conf

  • Note the path to the website files listed in the DocumentRoot line. In the example below, this is the directory /var/www/html.

    [root@localhost ~]# vi /etc/apache2/sites-enabled/example.com.conf

    <VirtualHost *:80> ... ServerAdmin webmaster@localhost DocumentRoot /var/www/html ... ErrorLog ${APACHE LOG DIR}/error.log CustomLog ${APACHE LOG DIR}/access.log combined

  • Press the [ESC] key.
  • To exit vi and save the file, enter the command :wq and then press Enter.

 

Nginx
  • Establish an SSH connection to your previously used server and log in as an administrator. You can find instructions in the following article: Connecting to a Linux server via SSH
  • Open the Nginx configuration directory.

    [root@localhost ~]# cd /etc/nginx

  • Open the main Nginx configuration file with the vi editor. This is usually the nginx.conf file. To do this, adapt the command below and then enter it:

    [root@localhost ~]# vi /etc/nginx/nginx.conf

  • Search the main configuration file for lines that contain 'include'. Then check which other configuration files or directories are loaded (e.g., sites-enabled/*).
  • Make a note of the required configuration files or directories and their paths.
  • To find the root directive that specifies the path to the website files, enter the following command:

    [root@localhost ~]# grep -R 'root' /etc/nginx/

    This command searches all files below /etc/nginx for the character string 'root'. The output shows you the files and the corresponding lines in which the root directive is set. The grep output can contain several lines if Nginx hosts several websites (server blocks). Each line shows the path of the configuration file, and the line in which the root directive is set. Example: etc/nginx/sites-available/example.com: root /var/www/example.com/html;

    In this example, the path /var/www/example.com/html is used as the root directory for the example.com website.

  • Note the path of the root directory.
  • Check the contents of the root directory. To display the contents, enter the following command:

    [root@localhost ~]# ls -l /PFAD

    Example:

    [root@localhost ~]# ls -l /var/www/example.com/html

Back up MySQL database

To back up the MySQL database for your website, you need to know the access data for the MySQL database. You will also need the following information:

  • Port
  • Host
  • Name of the database

If you know the access data for the MySQL database, you can skip this section.

Determining access data

The following explains where you can find the MySQL access data:

WordPress

In WordPress, you can find the MySQL access data in the wp-config.php file. This is located in the root directory of your WordPress installation.

Typical paths look like this, for example:

/var/www/html/wp-config.php

or

/var/www/example.com/wp-config.php /** The name of the database for WordPress */ define('DB_NAME', 'db123456789');

/** MySQL database username */ define('DB_USER', 'dbo123456789');

/** MySQL database password */ define('DB_PASSWORD', 'Secret_Password');

/** MySQL hostname */ define('DB_HOST', 'db123456789.hosting-data.io');

/** WordPress Database Table prefix. */$table_prefix = 'abcd_';

Websites without CMS

For websites that access a database directly and do not use a CMS, the storage of access data depends on the individual configuration. The access data is often stored in configuration files that are used by the respective scripts. To find the access data in this case, you must search for database connection parameters in the PHP, Python, Java, or other backend files, or refer to the manufacturer's documentation.

Export MySQL database

To back up a MySQL database, use the mysqldump tool, which is supplied with most MySQL installations. Replace the placeholders in the command below and then enter the command.

[root@localhost ~]# mysqldump --no-tablespaces --port PORTNUMMER --host=HOSTNAME --user=USERNAME --password=PASSWORD DATABASE_NAME | gzip > /root/dbdump.sql.gz

Caution

If you enter the password directly in the command after --password=, it will be saved in plain text in the command history (bash history) of your server. To avoid this, you can specify the parameter --password without a value. In this case, you will be prompted to enter a secure password after sending the command, during which your entry will remain invisible.

Example:

[root@localhost ~]# mysqldump --user=USERNAME --password DATABASE_NAME > /root/dbdump.sql

After entering the command, the database is exported to the root directory. The file name is dbdump.sql.gz.

Note

If your file names, passwords, or usernames contain special characters, you must enclose them in single quotation marks (') in the mysqldump or mysql command.

Example: mysqldump [...] --password='%gCjmnrmLk!xnSefw'

Save website files and exported MySQL database locally

Save the copy of the website files and the exported MySQL database to your local computer. This is a crucial step before you start reinstalling the operating system. You can use the FileZilla program for this. FileZilla is available for computers with Windows, macOS and Linux operating systems.

You can download the latest installation file for your operating system from the following page: https://filezilla-project.org/download.php?type=client

To establish a connection to your server with FileZilla to download the copy of the website files and the exported MySQL database to a local computer, complete the following:

  • Start FileZilla on your local computer.
  • Enter the IP address of the server in the Server field.
  • Enter the user name root in the User field.
  • In the Password field, enter the password you have set.
  • Enter port 22 in the Port field.
  • Click on Connect. The connection to the server is established. The directories located on your client are displayed in the area on the left. The directories located on your server are displayed in the area on the right.
  • Create a directory on your local computer.
  • Select the root directory on your server and then copy it to the desired directory on your local computer using drag-and-drop. Your exported database (dbdump.sql.gz) will be copied from this folder also.
  • Also copy any required configuration files or directories to the desired directory on your local computer using drag-and-drop.

Reinstalling the operating system

Carry out the reinstallation of the operating system via your IONOS Cloud Panel.

Caution

All data on the VPS will be deleted.

You can find instructions on how to install a new image in the following article: Reinstallng an image (VPS)

Installing applications on the new server

Once the new operating system has been installed, you must rebuild the environment. To do this, you must install the required applications on your new server.

Caution

Check the necessary system requirements before installation. You can also find out about any compatibility problems on the software manufacturer's website.

Install Apache, MySQL/MariaDB, and PHP

Instructions on how to install Apache, MySQL/MariaDB, and PHP can be found in the following articles:

Installing the LAMP stack on a server (AlmaLinux 9 and Rocky Linux 9)

Installing the LAMP stack on a server with Debian or Ubuntu

Installing Nginx

Instructions on how to install Nginx are listed in the following article:

Installing NGINX Open Source

Installing Plesk

You can find instructions on how to install Plesk in the following articles:

Installing Plesk (Linux VPS and migrated Cloud Servers)

Installing Plesk (Windows VPS and migrated Cloud Servers)

Installing WordPress

You can find instructions on how to install WordPress on a server in the WordPress documentation. This can be found on the following page:

https://developer.wordpress.org/advanced-administration

Securing the operating system and application

After installing the new operating system, adjust all necessary security settings and configurations of the server. This applies to both the new operating system and the installed applications.

Information on some fundamentally important security measures can be found in the following article: Important security information for your Linux server (part 2 of 2)

Import website files

Apache
  • Establish an SSH connection to your new server and log in as an administrator.
  • Also open FileZilla.
  • Copy the backed up data and configuration files with FileZilla using drag-and-drop into the corresponding directories on your new server.
  • Check the configuration files as well as the paths and settings that were specific to the old server environment and adjust them if necessary.
  • To restart Apache, switch to the program you used to establish the SSH connection and enter the following command:
     

    AlmaLinux and Rocky Linux

    [root@localhost ~]# sudo systemctl restart httpd

    Debian and Ubuntu

    [root@localhost ~]# sudo systemctl restart apache2

  • Check the scripts you are using and adjust them if necessary.
  • Test the website and the configuration.
 
Nginx
  • Establish an SSH connection to your new server and log in as administrator.

  • Also open FileZilla.

  • Copy the backed up data and configuration files with FileZilla using drag-and-drop into the corresponding directories on your new server.

  • Check the configuration files as well as the paths and settings that were adjusted to the old server environment and update them if necessary.

  • To restart Nginx, switch to the program you used to establish the SSH connection and enter the following command:

    [root@localhost ~]# sudo systemctl restart nginx

  • Check the scripts you are using and adjust them if necessary.

  • Test the website and the configuration.

 
Importing the MySQL database
  • Open FileZilla.
  • Copy the exported database to the corresponding directory on your new server using drag-and-drop.
  • Switch to the program you used to establish the SSH connection.
  • Open the directory in which the exported database is located.
  • To restore your data, execute the mysql command according to the scheme below. Replace the placeholders written in capital letters with the access data of the database in which you want to restore the data.

    [root@localhost ~]# gunzip -c FILENAME | mysql --user=USERNAME --password=PASSWORD DATABASE

  • Check the security settings of your MySQL database.

Move WordPress blog

You can find instructions on how to import your backed up WordPress blog on the following page:

How to carry out WordPress migration step by step (IONOS Digital Guide)

Completion and examination

DNS settings: As the IP address of your VPS does not usually change during a new installation, you do not need to change anything in the DNS.

Function test: Check the website for script errors and database connections.

Security: Adjust the firewall rules and security settings of your new operating system immediately.