• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / Linux sysadmin tutorials linux system administrator / 3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx

3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx

Table of Contents

Toggle
    • 1#Backup using mysqldump & zip SFTP client.
      • #2 SCP: copying files & directories one sever to another server remote
        • 1) If we want to copy a file from a local machine to a remote machine:
        • 2) If we want to copy a file from remote machine to our local machine.
      • # 1. Enable roor login in Linxu serer
    • Incase of Portnumber change
    • 2nd way
    • #3 Rsync (remote sync data to local & remote to remote)
  • File Transfer rsync /scp
  • Rsync web root Directory
  • Rsync the apache conf
  • Rsync php config file
  • Rsync mysql conf
      • #1.1 pairing two servers with ssh key (Optional)
      • generating ssh keys
    • adding public key to the Destination server which one connect

1#Backup using mysqldump & zip SFTP client.

export mysqldump
zip www directory & server config files
download to local computer
install new latest version of Softwares LAMP or LEMP
upload
& configuration files & Data
assign users from root to server user.
remote transfer between two linux servers ,rsync

#2 SCP: copying files & directories one sever to another server remote

scp command
secure copy,
scp source user@destinationip: pathtosave
connect remote server by ssh keys

1) If we want to copy a file from a local machine to a remote machine:

syntax:

scp [file_name]  remoteuser@remotehost:/remote/directory

2) If we want to copy a file from remote machine to our local machine.

syntax:

scp user@remotehost:/home/user/file_name .

scp /var/www/bak.zip root@192.168.0.1: /var/www/
or just delete the html directory in new server
scp -r /var/www/html root@192.168.0.1 /var/www/html
3rd or copying only internal file of html
scp -r /var/www/html/* root@192.168.0.1 /var/www/html
asks for password enter root password.

# 1. Enable roor login in Linxu serer

incase ssh disabled root login.  enable root login
in sshd.config file
and
restart sshd.

enable disable password login

nano /etc/ssh/sshd_config
take backup cp
passwordauthentication yes/no
#comment
allow root password login yes/no
#comment
service ssh restart

Incase of Portnumber change

The default port is 22 if nobody changed configuration in the sshd_config file. You may also just append the port number after the host IP address.

2nd way

ssh-copy-id command
ssh-copy-id user@remoteip
enter password.
next time
ssh user@remoteip
login successful
no manual copying
for one-time use its better to use ssh password
once the file copied you can disable root login.
to avoid brute force attacks
or pairing ssh keys between two remote severs
public key source machine
private key in target machine
type scp to know manual page(command options)
scp -p22 /,pathtopublickey

#3 Rsync (remote sync data to local & remote to remote)

data between two servers syncs.
set a chrome job to backup daily/weekly.
apt install rsync
syncing data (1st time) to backup directory
rsync datadirectory/* /backupdir
rsync -r /var/www/html/ /etc/home/backup/
-r recursively subfolder & files
-a with users & file permissions attributes .files /hidden files
-av
 v verbose output
rsync root@remoteip:- /path/tosave /currentserverpath

File Transfer rsync /scp

Rsync web root Directory

rsync -avz –progress 111.222.333.444:/var/www/site1 /var/www/

Rsync the apache conf

rsync -avz –progress 111.222.333.444:/etc/apache2/* /etc/apache2/

Rsync php config file

rsync -avz –progress 111.222.333.444:/etc/php5/* /etc/php5/

Rsync mysql conf

rsync -avz –progress 111.222.333.444:/etc/mysql/* /etc/mysql/
remote file deleted /  source file deleted both will lost.
if new file added both gets new.
ssh root@111.222.333.444 ‘mysqldump -a -u root -ppassword > /root/alldb.sql’
-A dump all databases.
syncing to current server
rsync -avz –progress 111.222.333.444:/root/alldb.sql /root/
import
mysql -u root -ppassword < /root/alldb.sql
rsync is the best Backup solution on server for daily/weekly/monthly routines

#1.1 pairing two servers with ssh key (Optional)

with password
ssh user@remoteip
enter password
you done..
(but every time password entry, vulnerable to others.)

generating ssh keys

note: if you already have public in local desktop,
just copy another remote server, private key already at destination server.
or follow this
generating ssh key
ssh-keygen rsa -a -b 2048
or
ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa 
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519
root@ubuntu-s-2vcpu-4gb-intel-blr1-01:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
ls -l /root/.ssh/
cat /root/.ssh/id_rsa.pub

adding public key to the Destination server which one connect

nano ./ssh/authorizedkeys   not exost sometims
cd ./ssh
ls -la
copying public key to remote machine
scp (if root password login enabled or download & upload)
scp rsa.pub user@remotep: /pathtolocation

enter password

add public key to
./ssh/authorizedkeys
cat command (appends to end of the file)
file permissions
ssh folder 700
ssh files 600
chmod 700 ./ssh
chmod 600 ./ssh/*
Os kernel version & architecture
uname -r && uname -m
5.2.0-24-virtual
//Kernel version
Os architecture
X86_64 64bit
I686 32
distribution /os version
cat /etc/issue or lsab-release
Ubuntu 12.04.2 LTS \n \l
transfer ssh keys between two servers
transferring core data
/etc/sources/apt/list.deb
file & directories & MySQL dump
preparation
to check which services are running
service –status-all
connecting 2 servers ssh keys
cloning operating system to another disk
(windows desktop we use minitool,)
Migrating users & group
clone running linux server
another way.
cloning is to disk.
also read Linux performance tuning
Faqs
how to connect from one server to another server in linux
ssh [username]@[server IP]
root@ubuntu-s-2vcpu-4gb-intel-blr1-01:~# ssh root@159.65.149.73
root@159.65.149.73: Permission denied (publickey).
cd ~/.ssh

root@murali:~/.ssh# nano authorized_keys

on source server
cat /root/.ssh/id_rsa.pub
root@murali:~/.ssh# service ssh restart

Primary Sidebar

Linux sysadmin tutorials linux system administrator

  • top 10 apt & apt-get commands (most used) apt vs apt-get
  • If-Else Statements in Shell Scripting
  • linux commands pdf (files & Directories, zip & unzip process, search etc)
  • Find Files with Specific Text on Linux grep find command
  • linux performance tuning inode limit file descriptors tco, kernel etc
  • Variables and Data Types in Shell Scripting
  • Top 10 most used Cat commands with examples (create, view, append files)
  • Ip tables / ufw / firewall d commands for block port ip rate limiting
  • Top 10 zip / tar commands to compress & extract files in linux
  • TOP 10 mv & cp commands in linux to move & copy files in Linux
  • Top 10 GREP Commands in linux to search files directory words strings
  • lsof netstat commands to know listening ports in linux 3 ways
  • Upgrade Ubuntu from 18.04 (19.10) to 20.04 LTS command line or gui server | desktop
  • 3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx
  • linux system specs commands (CPU, Memory, Disk )speed, type. manufacture
  • linux sysctl command tweaks & hardening
  • linux security limits.conf deciding user limits process limits for nginx server
  • ulimit linux unlimited command unlimto set & know user limits open files file descriptor max user process etc.
  • red hat linux certification cost jobs salary syllabus courses fees
  • ufw firewall commads allow port enable disable ubuntu 20.04
  • ddos attack prevention
  • change ssh port in linux - avoid sshd ddos attacks
  • ping command
  • memcached install ubuntu wordpress
  • check linux version (lsb_release -a) ubuntu debian 32 or 64 bit
  • rsync command linux with examples comparison to scp
  • how to uninstall package in linux ubuntu rpm, yum apt-get
  • increase open file limit linux File descriptor ft nginx , mysql, lemp
  • remove repository ubuntu
  • htop commad memory details virtual vs shard vs resident
  • chown command in Linux with Examples
  • Kill PHP process
  • VIrtual Memory vs RSS Memory vs Shared memory in Linux
  • oom killer fixing it by configuration linux ubuntu
  • Install Lemp nginx mysql php fpm Stack on Debian 11 with repository
  • connect two remote servers linux command line
  • auto start after oom killer Mysql & php fpm nginx etc ubuntu wth systemd or cron job
  • load average Linux 1, 5, 15 min 2,4,8 cores explained
  • Control Structures in Shell Scripting
  • Shell Scripting Roadmap for Beginners to Advanced
  • awk commands with practical examples
  • Shell Scripting Tutorial for Beginners 🚀
  • find Command in Linux with Examples
  • sed Command in Linux with Examples (Beginner to Advanced)
  • Linux Text processing commands in with Examples
  • linux disk management commands
  • fdisk command in linux with examples
  • how to add a new disk in linux
  • Linux mount Command with Examples
  • fstab options with examples
  • Top 50 Shell Scripting Interview Questions and Answers
  • Linux Networking Interview Questions and Answers
  • Linux Networking Commands Cheat Sheet with Examples pdf
  • Netstat & SS Commands cheat sheet with examples Interview Questions
  • Nmap Cheat Sheet – Network Scanning & Security
  • Bash Brackets ([], (), {}, $( ), $(( ))) – Types, Uses & Examples

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy