How To Create Back-Up Of VPS Server

In creating a back-up of a VPS server, there are three things you must take care of:

(i) All the files must be backed up;

(ii) The MySql database should be backed up;

(iii) A copy of the data base should be either downloaded onto your computer and/or transferred to another VPS so that if there is a hard disk failure on the first VPS, your back-up should not be lost.

There are several ways of creating a back-up of the VPS server. Let’s look at the manual method first.

Step I: Make A Back-Up Of the Old Site Files (Not Including Database)

(i) Find the “root” of your site. The easiest way to do is to create a php file (called phpinfo.php) and upload it to your site containing the following:

The contents of the php file should be:

// Show all information, defaults to INFO_ALL

// Show just the module information.
// phpinfo(8) yields identical results.


Now when you access phpinfo.php in your browser, it will show all information relating to the server inclusing the


which may be


Now in putty (or another SSH client), go to the root folder with this command:

cd /var/www/html/

To see the contents of the folder, type


Now copy all the files and convert it into a tar file with the command:

tar -cpzf backup_060412.tar.gz *

You can name the file with a descriptive title and date so you know how old it is. The (*) sign indicates that all files have to be copied into the tar file. If there are already any backup files in the folder, move/ delete them as otherwise they will also get include and bloat the file size.

If you make an error, you will get the cryptic/ whimsical message:

tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.

If you did it right, in a couple of seconds/ minutes (depending on the size) you should have a tar file by the specified name.

Step II: Make A Back-Up Of the Database:

To make a backup of ALL databases, run the following command:

mysqldump --all-databases -uuser -ppassword >database060412.sql

‘uuser’ mean ‘u + name of the user’ while ‘ppassword’ means ‘p + user’s password’

You can name the file in a descriptive manner to aid identification.

Step III: Download the tar and database back up files (optional) to your computer:

This may not be feasible if the file sizes are high and you have a slow connection.

Step IV: Transfer the files to the new server:

(i) Open a SSH session for your new server

(ii) locate the root of the site in the manner done earlier and go there

(iii) Download the tar and database file from the old server to the new server’s root folder with this command




Check the contents of the site’s root folder with the command ls

Its’ a good idea to do this exercise periodically – once a week or once a month – depending on your posting frequency so that you can enjoy peace of mind.

Leave a Reply

Your email address will not be published. Required fields are marked *