For the rest of my Linux experience, I’ve been doing a lot of backups. One tool that I can rely on is “scp” (Secure Copy).
Well, I’d recommend this tool when copying files from server or vise-versa.
Here’s the how to use it:
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2
In this snippet, we only need the “user@host1:]file1
There are also popular tools like rsync, wget, or version controls like git, etc… when downloading files, synching projects etc. and I will post about it later.
Anyways, here’s my code snippets for scp:
“For this snippets, suppose we have a server named “google-server.com” and we had files named twitter.txt and facebook.txt under /home/cliper/”
Copy (download) multiple files: twitter.txt, facebook.txt from google-server.com
// note, we use brackets together with a back-slash to separate multiple files. scp [email protected]:/home/cliper/\{twitter.txt,facebook.txt\}
Copy (download) twitter.txt from google-server.com
scp [email protected]:/home/cliper/twitter.txt
Uploading files to the server is much like the command above. In the following examples, we have server1.com as our target server and we have a folder /home/cliper/ there. Assumed that we had a Linux box locally when sending the files to server1.com. Now take a look at the difference. So if we have /home/mylocal_linux_pc/file.txt you will do something like..
Upload files to server1.com
scp /home/mylocal_linux_pc/file.txt [email protected]:/home/cliper/