Use ZIP and SCP to archive and copy files remotely
We have a folder that we want to archive into a .zip
file and copy it to a linux server via scp
(secure copy, which uses the ssh
protocol).
Let’s add the files to a zip archive first, we can use the zip
utility with the -r
parameter to recursively add all files (*
) in the current folder and subfolders:
$ zip docker-1.zip -r *
adding: compose.yml (deflated 66%)
adding: config.inc.php (deflated 63%)
adding: docker-compose.yml-old (deflated 57%)
adding: Dockerfile.mariadb (deflated 19%)
adding: Dockerfile.nginx (deflated 18%)
adding: Dockerfile.php (deflated 30%)
adding: Dockerfile.phpmyadmin (deflated 24%)
adding: Dockerfile.php-old (deflated 30%)
adding: html/ (stored 0%)
adding: html/index.php (stored 0%)
adding: html/test.php (deflated 4%)
adding: html/mariadb.php (deflated 50%)
adding: html/404.html (stored 0%)
adding: nginx.conf (deflated 48%)
We can then supply parameters to the scp
command, to copy the resulting archive.
We use an alternate port via the -P
parameter, and a ssh
keypair with the -i
parameter.
$ scp -P 125 -i ~/Documents/aws/my-aws1-keypair1.pem docker-1.zip admin@IP.IP.IP.IP:/home/admin/
docker-1.zip 100% 6209 116.4KB/s 00:00