Copying files from a development machine or a server to another one may take up a lot of time, resources and traffic which dependent on the task may be more or less a problem. There are common Linux/Unix tools like scp and rsync to do the job, but they may be a wrong choice dependent on the task like:
- copy a lot of small files (like node_modules) are big like text files or images in uncompressed formats like BMP or TIFF
- have special attributes set, which you want to transport over the wire (like permissions or user/group IDs set)
- files with encoding in names, which should be just transferred with errors
The most common Solution in both Directions
These are the most common combination to copy files using tar to compress and ssh for transport (using pipes) which may be suitable for most solutions.
Copy the folder data/ from current machine (development machine or current server) to remote server or system to folder /opt. The sever must support ssh and have tar installed, which is common for most Linux/Unix systems.
tar czf - data/ | ssh user@remoteserver "cd /opt && tar -xvzf - "
Copy the folder data/ in /opt to current machine (development machine or current server) from remote server or system. The server must support ssh and have tar installed, which is common for most Linux/Unix systems.
ssh user@remoteserver "cd /opt && tar -cfz data/" | tar xfzv
Deeper understanding
If you want to get a deeper understanding what all the parameters do, where to use them and which one you may need for which task, check the full article on my site: qameta.com.
Top comments (0)