Back Up and Restore Your Linux Server

Step 1: New Server

   So you have a new server, you are happy and excited to use it but you are still hanging up with the old server due to your data in it. Lets move your data to new server.

 

You need to download putty from http://www.putty.org/ to connect with ssh.

 

Checklist:

1-      New server operating system should be same as old server

2-      Make sure kernel and version of OS(operating system) is same.

 

How to check your OS and its versions as well kernel?

 

Login to putty and then type the command in ssh

 

lsb_release -a

 

it will print out version and OS.

 

To check kernel type command

 

uname -r

 

if your os version or kernel doesn’t match with old one login to old server and run following command

 

for centos/Redhat   

yum clean all

yum install update -y

 

for Debian/Ubuntu

apt-get update -y

apt-get upgrade -y

 

 once updates are done type reboot and press enter. Wait few minutes for server to be back online.

 

Now you are ready to move your old server to new server

 

Backup Your Server's OS

Making a backup of your OS is a very simple. Once you are logged into the server and at a command line make the directory to store the backup.

mkdir /backups

Now we will create a compressed version of the Operating System in one single file (tarball) using the tar command.

For RedHat/CentOS and Fedora.

tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules /

For Debian /Ubuntu run the following command:

tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/network/interfaces --exclude=/etc/udev/rules.d/70-persistent-net.rules /

 

Once the command completes the tarball will be located at /backups/backup.tgz

 

Restore Your Server's OS From a Backup

Now move the tarball to the server you want to restore. use commands like this to copy it to the new server’s hard drive:

mkdir /backups

scp root@old_server_IPV4:/backups/backup.tgz /backups

 

Replace "Old_server_IPV4" with the main IP address of old server.

Accept all messages and enter the root users password of old server when asked and the transfer will begin.

 

Once the transfer has completed run this command to extract the tarball to restore your Operating System.

 

tar xvpfz /backups/backup.tgz -C /

now type ifconfig command and match network setting with your Eth0, Eth1 or whatever network card name is.

Reboot the server, Congratulations you have your new and shiny server running with all your data moved in it,

  • backup, restore, linux, migration
  • 0 Benutzer fanden dies hilfreich
War diese Antwort hilfreich?

Powered by WHMCompleteSolution