Backup Server to Server Linux scp simplest way

Summary: In this artical I have tried to explain how to backup your server data and transferred to another server with all current permission and directory structure.
Following the steps will leads you to take backup of a server and deployed it into another server.
Server1 represent the current running server which need to be backup and server2 represent newly deployed server to which the backup will be transferred.

1: ssh
2: enter passwrod:
3: Checkout your server available space
4: Command is # df -h
5: If you have enough space on the server to compress your data then compress first
Server1# tar -cvzf yourfilename.tar.gz yourfilename
6: or you can take the whole directory to compress
Server1# tar -cvzf yourdirectory.tar.gz yourdirectory/.*
You have take the backup of important files and folders.
7: Take backup of
–>Configuration files
-All the configuration files of application you are running on the server.
8: Take backup of /var/www/html/.* in CentOs and /var/www/html/sites-availble in ubuntu.

When the tar.gz is completed then transfer the compressed data to another server for backup.
9: If you do not have much more space on the server then you can transfer the open data from one server to another one.

Half of the job is done here.

10: Login to your second server through ssh

11: Create a folder there with the name of backup-server1 if you have enough space.
Server2# mkdir /var/www/backup-server1

12: Now come back to terminal 1st ( server 1)

13: Copy all the tar files to server2 by the following commands
scp -drp folder1.tar.gz
scp -drp folder2.tar.gz
scp -drp folder3.tar.gz
scp -drp folder4.tar.gz

all Your data will be backup to server2.
13: To Transfer the open file run the following commands
scp -drp /var/www/html/*
but first you have to create a folder on the server2 in /var/www/html/ then run the command above.

14: Check your data size on both the servers.

15: Backup /var/log/.* Directory as well and delete all the log files to create space on your server1.

This is an overview of how to take backup server and make it possible to transfer to another server. if you are facing any issue on taking backup. i will be happy to assist you from here. so feel free to post the issue you are facing.

Leave a Reply

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