Refer here

Backup our sytem

sudo rsync -aAXv --delete --dry-run --exclude=/dev/* --exclude=/proc/* --exclude=/sys/* --exclude=/tmp/* --exclude=/run/* --exclude=/mnt/* --exclude=/media/* --exclude="swapfile" --exclude="lost+found" --exclude=".cache" --exclude="Downloads" --exclude=".ecryptfs" /source /destination

Change the partition format if needed

df -T /run/media/alu/alu

sudo unmount /dev/sdv1
sudo mkfs.ext4 /dev/sdb1 -L 'ALU'

lsblk

Restore the system

mkdir -p /mnt/usb/
mount /dev/sda1 /mnt/usb
rsync -aAXv --delete --exclude="lost+found" /mnt/usb/ /mnt/system

If you use pem file to access to remote ec2 address, usually it’s like below

ssh -i ubuntu.pem ubuntu@ip_address

But how to access the remote ec2 using just one line? For example, use sftp, ssh, scp command. You can achieve that by the following:

cat ~/.ssh/id_rsa.pub | ssh -i aws.pem ubuntu@ip_address “cat – >> ~/.ssh/authorized_keys”