From 74fd911e1b38251687a101b35d3328de746fbbc3 Mon Sep 17 00:00:00 2001 From: Tai Date: Mon, 4 Jan 2021 15:39:37 -0800 Subject: [PATCH] Added rsync notes --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 5cca6e1..ff53efc 100644 --- a/README.md +++ b/README.md @@ -132,3 +132,41 @@ Check total disk usage ``` sudo df -h ./ ``` + +## Random Rsync Notes For Container Migration +Remember to docker-compose down everything inside local machine so nothing shows up on docker container ls. +``` +# Generate keys. Choose defaults. Public key saves to ~/.ssh/id_rsa.pub +# Why do we do this? Because we set PermitRootLogin prohibit-password earlier. +# So we can only login root on the remote server via rsa key. + +ssh-keygen -t rsa +cat ~/.ssh/id_rsa.pub + +# Installing Rsync. Local and remote server. 2 installs total. +sudo apt update +sudo apt install rsync + +# Login to remote server +sudo su # to be the root user +mkdir ~/.ssh # if it didn't exist already +cd .ssh +nano authorized_keys # Append/Paste lines from id_rsa.pub generated from local server. + # Then save an exit. + +# Back to your local server... The command +rsync -aP -e "ssh -i /home//.ssh/id_rsa" + +# Copy whole folder from source to destination example +rsync -aP -e "ssh -i /home/sammy/.ssh/id_rsa" ~/docker/someapp root@:/home/sammy/ + +# Copy contents of folder from source to destination example # There is a / in front of ./docker in this case. +rsync -aP -e "ssh -i /home/sammy/.ssh/id_rsa" ~/docker/someapp/ root@:/home/sammy/ + +# Rsync Flags +-a # The -a option is a combination flag. It stands for “archive” and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions +-e # specify ssh command... +-v # verbose +-P # progress + partial combined +-h # output numbers in human readable format +```