Copying files

by Gisle Hannemyr

This chapter tells you to copy files from your own personal computer to a web-host, to transfer individual files between two different web-hosts, and to sync two web-hosts.

Table of contents

Introduction

[TBA]

Copying and syncing individual files

You may want to copy files between your own personal computer and the web-host without using the file upload functions that are part of Drupal.

Below are some notes about the tools that are available for this:

scp

The program scp (secure copy) is a CLI tool to transfer files between two computers It is based on the Secure Shell (ssh) protocol.

It is available on Gnu/Linux and Apple Macintosh OS X.

For example, to copy all shell scripts in bob's home directory on one computer to another, do:

$ scp /home/bob/*.sh bob@example.com:/home/bob
bob@example.com's password:

WinSCP

WinSCP (Windows Secure Copy) is a free software GUI client for sftp, ftp, WebDAV and scp for Microsoft Windows. Its main function is secure file transfer between a local and a remote computer. Beyond this, WinSCP offers basic file manager and file synchronization functionality. For secure transfers, it uses Secure Shell (ssh) and supports the scp protocol in addition to sftp.

FileZilla

FileZilla is free software. It is a cross-platform application for transferring files between computers, consisting of the FileZilla Client and FileZilla Server. The client offers a GUI. Client binaries are available for Microsoft Windows, Gnu/Linux, and Mac OS X. The client supports ftp, sftp and ftps (ftp over SSL/TLS). However support for SFTP is not implemented in the FileZilla Server.

Bulk copying

The standard Gnu/Linux program used to synchronize files and directories between two different systems is rsync.

The most used rsync-command for copying between two systems is shown below:

$ rsync -a local-dir username@remote-host:remote-dir
username@remote-host's password:

The -a flag stands for "archive". This flag syncs recursively and preserves symbolic links, special and device files, modification times, groups, owners, and permissions.

This will recursively copy local-dir into remote-dir.

$ rsync -av --dry-run html username@remote-host:/var/www
username@remote-host's password:

The -v flag stands for "verbose". This flag syncs recursively and preserves symbolic links, special and device files, modification times, groups, owners, and permissions.

is run, rsync will use SSH to connect as user to remote-host. Once connected, it will invoke the remote host's rsync and then the two programs will determine what parts of the file need to be transferred over the connection.

See alsoThere is a nice tutorial about How To Use Rsync to Sync Local and Remote Directories on a VPS at DigitalOcean.com. It provides some background information about rsync and covers all the basic usage of this powerful utility.

Final word

[TBA]


Last update: 2015-10-30 [gh].